All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [PATCH v2 2/6] x86/mem-paging: correct p2m_mem_paging_prep()'s error handling
Date: Fri, 15 May 2020 17:15:05 +0200	[thread overview]
Message-ID: <83f6463c-6a61-e79b-cf1b-77589ef287c1@suse.com> (raw)
In-Reply-To: <2cccf9bb-3930-436d-65de-f0eb7dd0c498@citrix.com>

On 15.05.2020 16:40, Andrew Cooper wrote:
> On 23/04/2020 09:37, Jan Beulich wrote:
>> @@ -1816,9 +1816,19 @@ int p2m_mem_paging_prep(struct domain *d
>>              goto out;
>>          /* Get a free page */
>>          ret = -ENOMEM;
>> -        page = alloc_domheap_page(p2m->domain, 0);
>> +        page = alloc_domheap_page(d, 0);
>>          if ( unlikely(page == NULL) )
>>              goto out;
>> +        if ( unlikely(!get_page(page, d)) )
>> +        {
>> +            /*
>> +             * The domain can't possibly know about this page yet, so failure
>> +             * here is a clear indication of something fishy going on.
>> +             */
> 
> This needs a gprintk(XENLOG_ERR, ...) of some form.  (which also reminds
> me that I *still* need to finish my patch forcing everyone to provide
> something to qualify the domain crash, so release builds of Xen get some
> hint as to what went on or why.)

First of all - I've committed the patch earlier today, with Roger's
R-b, and considering that it had been pending for quite some time.

As to the specific aspect:

>> +            domain_crash(d);

This already leaves a file/line combination as a (minimal hint). I
can make a patch to add a gprintk() as you ask for, but I'm not
sure it's worth it for this almost dead code.

>> @@ -1843,13 +1852,24 @@ int p2m_mem_paging_prep(struct domain *d
>>      ret = p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K,
>>                          paging_mode_log_dirty(d) ? p2m_ram_logdirty
>>                                                   : p2m_ram_rw, a);
>> -    set_gpfn_from_mfn(mfn_x(mfn), gfn_l);
>> +    if ( !ret )
>> +    {
>> +        set_gpfn_from_mfn(mfn_x(mfn), gfn_l);
>>  
>> -    if ( !page_extant )
>> -        atomic_dec(&d->paged_pages);
>> +        if ( !page_extant )
>> +            atomic_dec(&d->paged_pages);
>> +    }
>>  
>>   out:
>>      gfn_unlock(p2m, gfn, 0);
>> +
>> +    if ( page )
>> +    {
>> +        if ( ret )
>> +            put_page_alloc_ref(page);
>> +        put_page(page);
> 
> This is a very long way from clear enough to follow, and buggy if anyone
> inserts a new goto out path.

What alternatives do you see?

Jan


  reply	other threads:[~2020-05-15 15:15 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23  8:34 [PATCH v2 0/6] x86/mem-paging: misc cleanup Jan Beulich
2020-04-23  8:37 ` [PATCH v2 1/6] x86/mem-paging: fold p2m_mem_paging_prep()'s main if()-s Jan Beulich
2020-05-14 15:45   ` Roger Pau Monné
2020-05-14 15:51     ` Jan Beulich
2020-05-15 12:02   ` Andrew Cooper
2020-04-23  8:37 ` [PATCH v2 2/6] x86/mem-paging: correct p2m_mem_paging_prep()'s error handling Jan Beulich
2020-05-14 15:57   ` Roger Pau Monné
2020-05-15 14:40   ` Andrew Cooper
2020-05-15 15:15     ` Jan Beulich [this message]
2020-05-15 20:02       ` Andrew Cooper
2020-04-23  8:38 ` [PATCH v2 3/6] x86/mem-paging: use guest handle for XENMEM_paging_op_prep Jan Beulich
2020-05-14 16:13   ` Roger Pau Monné
2020-05-15 14:14   ` Ping: " Jan Beulich
2020-05-15 14:46   ` Andrew Cooper
2020-05-15 16:40   ` Wei Liu
2020-04-23  8:38 ` [PATCH v2 4/6] x86/mem-paging: add minimal lock order enforcement to p2m_mem_paging_prep() Jan Beulich
2020-05-14 16:25   ` Roger Pau Monné
2020-05-15  9:46     ` Jan Beulich
2020-05-15 10:21       ` Roger Pau Monné
2020-04-23  8:39 ` [PATCH v2 5/6] x86/mem-paging: move code to its dedicated source file Jan Beulich
2020-05-14 16:29   ` Roger Pau Monné
2020-05-15 15:45   ` Andrew Cooper
2020-04-23  8:39 ` [PATCH v2 6/6] x86/mem-paging: consistently use gfn_t Jan Beulich
2020-05-14 16:36   ` Roger Pau Monné
2020-05-15 15:49   ` Andrew Cooper
2020-05-15 15:52     ` Andrew Cooper

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=83f6463c-6a61-e79b-cf1b-77589ef287c1@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=roger.pau@citrix.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.