Re: [Xen-devel] [PATCH v4 13/18] x86/mem_sharing: Skip xen heap pages in memshr nominate

2020-01-20 Thread Tamas K Lengyel
On Mon, Jan 20, 2020 at 9:23 AM Jan Beulich  wrote:
>
> On 08.01.2020 18:14, Tamas K Lengyel wrote:
> > Trying to share these would fail anyway, better to skip them early.
> >
> > Signed-off-by: Tamas K Lengyel 
>
> Reviewed-by: Jan Beulich 
> albeit I wonder if this couldn't be further generalized by ...
>
> > --- a/xen/arch/x86/mm/mem_sharing.c
> > +++ b/xen/arch/x86/mm/mem_sharing.c
> > @@ -852,6 +852,11 @@ static int nominate_page(struct domain *d, gfn_t gfn,
> >  if ( !p2m_is_sharable(p2mt) )
> >  goto out;
> >
> > +/* Skip xen heap pages */
> > +page = mfn_to_page(mfn);
> > +if ( !page || is_xen_heap_page(page) )
> > +goto out;
>
> ... checking for a zero type ref count (the only means to permit
> a type change) here, and maybe also ->count_info to fit what
> page_make_sharable() expects.

Not sure I follow you, type count is checked by page_make_sharable but
it has to be exactly 1:

/* Check if page is already typed and bail early if it is */
if ( (page->u.inuse.type_info & PGT_count_mask) != 1 )
{
spin_unlock(>page_alloc_lock);
return -EEXIST;
}

I specifically want to avoid calling page_make_sharable on xen heap
pages because they end up printing an error to the console which is
very annoying.

Tamas

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v4 13/18] x86/mem_sharing: Skip xen heap pages in memshr nominate

2020-01-20 Thread Jan Beulich
On 20.01.2020 17:32, Tamas K Lengyel wrote:
> On Mon, Jan 20, 2020 at 9:23 AM Jan Beulich  wrote:
>>
>> On 08.01.2020 18:14, Tamas K Lengyel wrote:
>>> Trying to share these would fail anyway, better to skip them early.
>>>
>>> Signed-off-by: Tamas K Lengyel 
>>
>> Reviewed-by: Jan Beulich 
>> albeit I wonder if this couldn't be further generalized by ...
>>
>>> --- a/xen/arch/x86/mm/mem_sharing.c
>>> +++ b/xen/arch/x86/mm/mem_sharing.c
>>> @@ -852,6 +852,11 @@ static int nominate_page(struct domain *d, gfn_t gfn,
>>>  if ( !p2m_is_sharable(p2mt) )
>>>  goto out;
>>>
>>> +/* Skip xen heap pages */
>>> +page = mfn_to_page(mfn);
>>> +if ( !page || is_xen_heap_page(page) )
>>> +goto out;
>>
>> ... checking for a zero type ref count (the only means to permit
>> a type change) here, and maybe also ->count_info to fit what
>> page_make_sharable() expects.
> 
> Not sure I follow you, type count is checked by page_make_sharable but
> it has to be exactly 1:
> 
> /* Check if page is already typed and bail early if it is */
> if ( (page->u.inuse.type_info & PGT_count_mask) != 1 )
> {
> spin_unlock(>page_alloc_lock);
> return -EEXIST;
> }

Which is after a successful get_page_and_type(). Prior to that,
therefore, the count ought to be zero. But maybe I'm very confused
- see also my comments on patch 14, where I spotted this very same
anomaly.

> I specifically want to avoid calling page_make_sharable on xen heap
> pages because they end up printing an error to the console which is
> very annoying.

That's fine. I'm not asking to drop what you're doing. Instead I'm
asking whether you couldn't bail early in even more cases.

Jan

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v4 13/18] x86/mem_sharing: Skip xen heap pages in memshr nominate

2020-01-20 Thread Jan Beulich
On 08.01.2020 18:14, Tamas K Lengyel wrote:
> Trying to share these would fail anyway, better to skip them early.
> 
> Signed-off-by: Tamas K Lengyel 

Reviewed-by: Jan Beulich 
albeit I wonder if this couldn't be further generalized by ...

> --- a/xen/arch/x86/mm/mem_sharing.c
> +++ b/xen/arch/x86/mm/mem_sharing.c
> @@ -852,6 +852,11 @@ static int nominate_page(struct domain *d, gfn_t gfn,
>  if ( !p2m_is_sharable(p2mt) )
>  goto out;
>  
> +/* Skip xen heap pages */
> +page = mfn_to_page(mfn);
> +if ( !page || is_xen_heap_page(page) )
> +goto out;

... checking for a zero type ref count (the only means to permit
a type change) here, and maybe also ->count_info to fit what
page_make_sharable() expects.

Jan

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v4 13/18] x86/mem_sharing: Skip xen heap pages in memshr nominate

2020-01-08 Thread Tamas K Lengyel
Trying to share these would fail anyway, better to skip them early.

Signed-off-by: Tamas K Lengyel 
---
 xen/arch/x86/mm/mem_sharing.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index b8a9228ecf..baa3e35ded 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -852,6 +852,11 @@ static int nominate_page(struct domain *d, gfn_t gfn,
 if ( !p2m_is_sharable(p2mt) )
 goto out;
 
+/* Skip xen heap pages */
+page = mfn_to_page(mfn);
+if ( !page || is_xen_heap_page(page) )
+goto out;
+
 /* Check if there are mem_access/remapped altp2m entries for this page */
 if ( altp2m_active(d) )
 {
@@ -882,7 +887,6 @@ static int nominate_page(struct domain *d, gfn_t gfn,
 }
 
 /* Try to convert the mfn to the sharable type */
-page = mfn_to_page(mfn);
 ret = page_make_sharable(d, page, expected_refcnt);
 if ( ret )
 goto out;
-- 
2.20.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel