[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH v2 2/2] xen/common: Use enhanced ASSERT_ALLOC_CONTEXT in xmalloc()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Henry Wang <Henry.Wang@xxxxxxx>
  • Date: Fri, 6 May 2022 12:03:23 +0000
  • Accept-language: zh-CN, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3ngeQtgrxCaWSrBPVmd67JBnD1aLnowqKALKoCu1V0g=; b=I5AajyWBttD+aoVrncfo1sVp9ByUGjMCdS39Qu62CgCK0YCdshNlFMF6zS3Nl5AegDG7gnJ5VPNqkOu7+elE2jXmcI7H8FW4pOPOLLPek2L6cCdNJQCE6cvSZoLn44JSPgOW1iH0PVlLWWAYsT62mpbY39dPexc+lbn5FMC7Gths7L8q8dH3Ni90lzXSX46FKxtDDVIRaSwcWLSbHQYCl6a1Zn99LMWJYHy0dFI9mt1rzUnLbzECWi9sGC79fDmXPWiNkVnCDMrEXzUV6pHedqUzEWdDwAGHa/uRs7Gt6L/N0JAKpqbY26bRE631LCajri8OEvNcniupY6qkf+o6Zg==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3ngeQtgrxCaWSrBPVmd67JBnD1aLnowqKALKoCu1V0g=; b=NlWm5hRQY6Xbq+VzP48YMaDAwP/QfcxYizN8bQ4kwp1GV7G3ftxPzY0LWZmRK4ua0djL+ECuZidh/MXKm3QJSxbTJN7XxTUEXKEB9YixYfbEEzV9X7mdYUdU1Mm9POZY+7Kemzma2a8KvO/ic760LWOgmou+zv5adJ2BAVZquMVZUBzjHKaKGcY1i0nj3ZN6uqiQmJ7t256ycKu6JgGmXYluG99w3XfOj+oYRroVhTlpB8JQEV4sT0tRdB2MNbsStJa9UzEtfupKDPvk0Z7uvABkSeGxrEQ0H5jcz3+6STBgVpDLAK/SSFBBgGzpuSyzwcJkYhRrtRH1qBIY4PTmkw==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=ntH+jH9s2SIop0JhZ2+C/ylcvr9r3Uwvsw1gPRmboCmohoCQF+R0XvEGjY2WcQ9TR8ulmxBhrneo0rdKyReuRo6u0MCu4teDc9WqECdkG8sh8Donwj8RDNouv+FydZ4mFReisa60kHSV5o5Ty+eXeF8cpCvRvKrQSvvr9L+/yb2m0sHrSOnGlCdHfpVo7lmUXvEIfaAVKv4zSWfbP3RBsL0XrYlouNN4wFoqIodj4gNdwvClEJi8iO4tShRmIhAZtogb4/H2lkxiM3uok3B5dkeQ5XZUT1oqOdtIxu9rUIGVsnsnUrm/PNrw41vinw82jFGi7DojvjCmeJG8SJq8fg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cgWIcq+TXEqFkn7ATUpLEeekh+D06WeDm6/iWfMAsKL4czylh3xRYBG9lEuHXXfF6jtDgoGkFGMUtMbos2mjYP91Vt+EeveJp8jx7Pf3m+VqV1Y1cZIgosG+4JKEVNr8WQGtlhpEthK7sOC3l61C4rXAQkdVuHZftm7RQOKhhSFen2XzF5B0+Fc9y0CvnRIov4sGolSTKSY+6yJ3Q65mKR/gqFW1EeMke/FznNgYWpEAXvqpJN5m2dp3bAmlKNTeYmG2mF9R4Zd54ATyWv4cjlrq5F+RYVWl0lJjKta6P6SwCnkFYhNXYOPFfx923jo2xAbv5uyhH4WiDO5Lb/nOTQ==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 06 May 2022 12:03:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYYQ1+wSNISpljvkG6pMKyJcwNSq0Rpx4AgAAWlnA=
  • Thread-topic: [PATCH v2 2/2] xen/common: Use enhanced ASSERT_ALLOC_CONTEXT in xmalloc()

Hi Jan,

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Friday, May 6, 2022 6:33 PM
> To: Henry Wang <Henry.Wang@xxxxxxx>
> Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>; Julien Grall 
> <julien@xxxxxxx>;
> Bertrand Marquis <Bertrand.Marquis@xxxxxxx>; Volodymyr Babchuk
> <Volodymyr_Babchuk@xxxxxxxx>; Andrew Cooper
> <andrew.cooper3@xxxxxxxxxx>; George Dunlap <george.dunlap@xxxxxxxxxx>;
> Wei Liu <wl@xxxxxxx>; Wei Chen <Wei.Chen@xxxxxxx>; Julien Grall
> <jgrall@xxxxxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Subject: Re: [PATCH v2 2/2] xen/common: Use enhanced
> ASSERT_ALLOC_CONTEXT in xmalloc()
> 
> On 06.05.2022 07:52, Henry Wang wrote:
> > --- a/xen/common/xmalloc_tlsf.c
> > +++ b/xen/common/xmalloc_tlsf.c
> > @@ -594,7 +594,7 @@ void *_xmalloc(unsigned long size, unsigned long
> align)
> >  {
> >      void *p = NULL;
> >
> > -    ASSERT(!in_irq());
> > +    ASSERT_ALLOC_CONTEXT();
> 
> For one - what about xfree()?

Oh you are definitely correct, thanks for pointing this out. I will
definitely change the assertion in xfree() as well in v3.

> 
> And then did you consider taking the opportunity and moving both to
> the respective pool alloc functions, thus giving even better coverage?

Yeah I would love to. But sorry about the question (just for learning):
I assume you are talking about code coverage, could you please kindly
add a little bit more detail to help me understand why adding the same
ASSERT_ALLOC_CONTEXT would help to a better coverage? Since...

> Granted there's one downside to moving it to xmem_pool_alloc(): Then
> the early zero-size and error returns won't be covered, so maybe we
> actually want checks in both places. 

...after reading these I have a feeling that we need to add the same
ASSERT_ALLOC_CONTEXT in the beginning of the xmem_pool_alloc,
xmalloc_whole_pages, and xmem_pool_free, while keeping
ASSERT_ALLOC_CONTEXT in _xmalloc. I think xmem_pool_alloc and
xmalloc_whole_pages are only called in _xmalloc and xmem_pool_free
is only called in xfree. Adding the same assertion in these three functions
is duplication of code?

Thank you for your explanation and patience.

> In xfree() I think the check
> would then also want to move ahead of the early return.

Sure, will do as you suggested.

Kind regards,
Henry

> 
> Jan


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.