[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:39:55 +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=UFNE7/+zluslQcX6pwyHXxsd++W2iDNOce2ssCCoTcM=; b=n43R5hRr630NkPQrAyFwhKV7UGFmKjFqXKMkuBOZQS77x86kMYsmqIrYq31HaOj91bKAx2ANQHpDJEapYgqEnw49bMIoReIHmZ5sTFGjdUbiBbefwqxf7uHWSK2qOxuk3/AbEAnVcgrhN2BxgcgYskCtVhBgTZCxlT0Z32OISLMcaKumq46W2RveDXkKZF240Fz0DCsKHuX4wb3chlxSKBFefODgOV+5nILBWMEEvEjAMXpbZFL3Frkso+Qm3+U1I0sEApcqYIZZcVgibNFKYL4YFKHs53dBaK39plBYwRRDce5nZYo7NSUV0FCiuuSkZ8M7T+i9VyuQO0VZLOkOKQ==
  • 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=UFNE7/+zluslQcX6pwyHXxsd++W2iDNOce2ssCCoTcM=; b=Wvd/ITjzwtqbDQ0efDsMaohdpz2jqUVMQaDklJFfQDcqWNwxZ04iTmeeOhS9OKbdhYLYf0I2rXtxiM/QlSSw97aEmbVXgqondO/wFTYhJdfB30a5wOsNyPoRQr/bkGaG6TVyqlPsPekZ/D5BNqsq8VLho/gMVmisL7UUGm3mkoZnyVkA+KRwF6IXOTP1YEMghYf5kCsQ/s71DEWpHrmf8tYG+anazDPKYYVQUbuU1YguTjk5NuU0yyUuxwkThPiCEKanrB6B6nQ0Ga8s8oGoy8yomILSfUutGCH75Xu/2fSRuQtk/2JYaEyhNEh8GOO0rB8bk8BkJZVXCtVCAZrxAg==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=DVcQjT/kz2UDVTXJl/p5LK1MG/mM0AVi6S73eqJzTVs53dGcH0NhHl9DEjEnzN7/K8OIYuZG+ghHtkeBBmCMFJ12Hm+uFhhxBg5XiRkMLFJOmu8TO1l9rYRanJ1PPrjLGw4Jh1PBzkVvbTrxs4lpk0pVN+TlfT/l41gHgqjCCxOiCnBSXy/Jf9zHtvGGNlIgqcyFmF6wIMno1Cb+IvPoHCLQIyryLn7Q6CArfWlPAHfWchlPV6/lLTl0nzFOFUtSzlNgab0H9X3mrOjlfzwLTTgVujuDwRJD4D6oXY3kzK7m77u0l4cgamAM3ZRgb/SZsI9vY9HXjv/ZfNkwkOd7VQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mYGlGCC1zLPQ6n+PMqt57GI6YeoeyNfjH/ibDM34mbMQCvfnyyfYXSNS9e19yLhido+a3TFmJFJFgg94LcFEeJvCF+ovRxkNpfgkEm0Jjm1hfLivOOCLU9WShz5OSSeD7canHsnaTNjjPRdvfEOnyGZnT1j9z93sWgWLzmZrvWhziLnjELOzwfikFttsuf3oxWYtejSMXKsvqL6ECQRdbTwG1juNsjG+MS/4PHUKNon5CppL0NNp3ZHtKW+XyrSEJ6IQFNMS7gLIkohKhnG+IUgEzlVq+aOm/tafNhnjbblo/McnbAy7j13EXJan0JCmT01FGdyXCAleX2L6Fllcdg==
  • 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:40:21 +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+wSNISpljvkG6pMKyJcwNSq0Rpx4AgAAWlnCAAAmQAIAAAnVQ
  • Thread-topic: [PATCH v2 2/2] xen/common: Use enhanced ASSERT_ALLOC_CONTEXT in xmalloc()

Hi Jan,

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> 
> On 06.05.2022 14:03, Henry Wang wrote:
> >> -----Original Message-----
> >> From: Jan Beulich <jbeulich@xxxxxxxx>
> >> Sent: Friday, May 6, 2022 6:33 PM
> >>
> >> 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,
> 
> xmem_pool_{alloc,free}() are what my comment was about. And "coverage"
> was meant as "if the assertions were there, more [potential] call sites
> would be covered". xmalloc_whole_pages(), as you ...
> 
> > 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?
> 
> ... validly note, is of no interest in this regard, as it's (1) a static
> helper and (2) would hit the checks in page_alloc.c.
> xmem_pool_{alloc,free}() otoh are non-static functions, so we will want
> to care about not only existing callers, but also potential future ones.

Great thanks for your explanation. This makes great sense, so I will add
ASSERT_ALLOC_CONTEXT in the beginning of xmem_pool_{alloc,free}().

Kind regards,
Henry

> 
> Jan


 


Rackspace

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