All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "George Dunlap" <George.Dunlap@eu.citrix.com>,
	"Ian Jackson" <iwj@xenproject.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Wei Liu" <wl@xen.org>, "Julien Grall" <julien@xen.org>,
	"Paul Durrant" <paul@xen.org>,
	"Michał Leszczyński" <michal.leszczynski@cert.pl>,
	"Hubert Jasudowicz" <hubert.jasudowicz@cert.pl>,
	"Tamas K Lengyel" <tamas@tklengyel.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v3 1/7] xen/gnttab: Rework resource acquisition
Date: Mon, 18 Jan 2021 09:23:57 +0100	[thread overview]
Message-ID: <57895dd4-10c7-18cb-bc44-25a45cb688a7@suse.com> (raw)
In-Reply-To: <a96bed35-df20-e77b-1b98-593aa5649ad9@citrix.com>

On 15.01.2021 17:57, Andrew Cooper wrote:
> On 15/01/2021 11:56, Jan Beulich wrote:
>>> +    /* Grow table if necessary. */
>>> +    grant_write_lock(gt);
>>> +    rc = -EINVAL;
>>> +    switch ( id )
>>> +    {
>>> +    case XENMEM_resource_grant_table_id_shared:
>>> +        vaddrs = gt->shared_raw;
>>> +        rc = gnttab_get_shared_frame_mfn(d, tot_frames - 1, &tmp);
>> ... this will degenerate (and still cause an error) when frame
>> is also zero, and will cause undue growing of the table when
>> frame is non-zero yet not overly large.
> 
> Urgh, yes - that is why I had the check.
> 
> In which case I retract my change between v2 and v3 here.
> 
>> As indicated before, I'm of the clear opinion that here - like
>> elsewhere - a number of zero frames requested means that no
>> action be taken at all, and success be returned.
> 
> The general world we work in (POSIX) agrees with my opinion over yours
> when it comes to this matter.

I assume you are referring to mmap()? I ask because I think there
are numerous counter examples (some even in the C standard):
malloc() & friends allow for either behavior. memcpy() / memmove()
happily do nothing when passed a zero size. read() / write()
are at least allowed to read/write nothing (and return success)
when told so. Otoh I notice that a zero vector count passed to
readv() / writev() is indeed an error, yet nothing is said at all
about individual vector elements specifying zero size.

Plus of course I don't think POSIX is the main reference point
here, when the rest of the hypercalls allowing for some form of
batching permit empty batches.

> I spent a lot of time and effort getting this logic correct in v2, and I
> do not have any further time to waste adding complexity to support a
> non-existent corner case, nor is it reasonable to further delay all the
> work which is depending on this series.  This entire mess is already too
> damn complicated, without taking extra complexity.
> 
> Entertaining the idea of supporting 0 length requests is really not as
> simple as you seem to think it is, and is a large part of why I'm
> stubbornly refusing to do so.

I'd be really happy to be educated of the complications; sadly
so far you've only claimed ones would exist without actually
going into sufficient detail. In particular I don't view placing 

    if ( size == 0 )
        return 0;

suitably early coming anywhere near "complexity". Even more so
that as per your reply you mean to undo removal of a respective
check, just that in your version it'll return an error instead
of success.

> I am going to commit this patch (with some of the other minor adjustments).

I'm not concerned enough of the introduced inconsistency to
outright veto you doing so, but I still don't think this is an
appropriate step to take under the present conditions.

Jan


  reply	other threads:[~2021-01-18  8:24 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 19:48 [PATCH v3 0/7] Multiple fixes to XENMEM_acquire_resource Andrew Cooper
2021-01-12 19:48 ` [PATCH v3 1/7] xen/gnttab: Rework resource acquisition Andrew Cooper
2021-01-15 11:43   ` Jan Beulich
2021-01-15 16:03     ` Andrew Cooper
2021-01-15 16:26       ` Jan Beulich
2021-01-15 16:27         ` Jan Beulich
2021-01-15 11:56   ` Jan Beulich
2021-01-15 16:57     ` Andrew Cooper
2021-01-18  8:23       ` Jan Beulich [this message]
2021-01-28 22:56         ` Andrew Cooper
2021-01-29  9:33           ` Jan Beulich
2021-01-29 17:44             ` Ian Jackson
2021-01-12 19:48 ` [PATCH v3 2/7] xen/memory: Fix acquire_resource size semantics Andrew Cooper
2021-01-12 20:15   ` Julien Grall
2021-01-12 20:57     ` Andrew Cooper
2021-01-12 21:05       ` Tamas K Lengyel
2021-01-12 19:48 ` [PATCH v3 3/7] tools/foreignmem: Support querying the size of a resource Andrew Cooper
2021-01-12 19:48 ` [PATCH v3 4/7] xen/memory: Clarify the XENMEM_acquire_resource ABI description Andrew Cooper
2021-01-12 19:48 ` [PATCH v3 5/7] xen/memory: Improve compat XENMEM_acquire_resource handling Andrew Cooper
2021-01-15 15:37   ` Jan Beulich
2021-01-28 23:32     ` Andrew Cooper
2021-02-01 14:12       ` Jan Beulich
2021-01-12 19:48 ` [PATCH v3 6/7] xen/memory: Indent part of acquire_resource() Andrew Cooper
2021-01-12 19:48 ` [PATCH v3 7/7] xen/memory: Fix mapping grant tables with XENMEM_acquire_resource Andrew Cooper
2021-01-15 16:12   ` Jan Beulich
2021-01-28 23:44     ` Andrew Cooper
2021-01-29  9:46       ` Jan Beulich
2021-01-29 18:18         ` Andrew Cooper
2021-02-01 12:56           ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57895dd4-10c7-18cb-bc44-25a45cb688a7@suse.com \
    --to=jbeulich@suse.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=hubert.jasudowicz@cert.pl \
    --cc=iwj@xenproject.org \
    --cc=julien@xen.org \
    --cc=michal.leszczynski@cert.pl \
    --cc=paul@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=tamas@tklengyel.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.