From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Liu Subject: Re: [PATCH] xen: simplify balloon_first_page() with list_first_entry_or_null() Date: Wed, 13 Nov 2013 20:54:49 +0800 Message-ID: <52837699.20405@oracle.com> References: <5283662D.1010500@oracle.com> <52836BDF.3090700@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VgZyI-0003jQ-AQ for xen-devel@lists.xenproject.org; Wed, 13 Nov 2013 12:55:02 +0000 In-Reply-To: <52836BDF.3090700@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: David Vrabel Cc: xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org On 11/13, 2013 20:09 PM, David Vrabel wrote: > On 13/11/13 11:44, Jeff Liu wrote: >> From: Jie Liu >> >> Simplify the code logic of balloon_first_page() by replacing >> the combination of list_empty() and list_first_entry() with >> list_first_entry_or_null(). As a net win, we can change this >> routine to inline as now it's one line. >> >> Signed-off-by: Jie Liu >> >> --- >> drivers/xen/balloon.c | 7 +++---- >> 1 file changed, 3 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c >> index b232908..0e4ca20 100644 >> --- a/drivers/xen/balloon.c >> +++ b/drivers/xen/balloon.c >> @@ -157,11 +157,10 @@ static struct page *balloon_retrieve(bool prefer_highmem) >> return page; >> } >> >> -static struct page *balloon_first_page(void) >> +static inline struct page *balloon_first_page(void) >> { >> - if (list_empty(&ballooned_pages)) >> - return NULL; >> - return list_entry(ballooned_pages.next, struct page, lru); >> + return list_first_entry_or_null(&ballooned_pages, >> + struct page, lru); >> } > > There's only one user of balloon_first_page(), can you remove > balloon_first_page() and just use list_first_entry_or_null()? Sure, will post the revised version a little while. Thanks, -Jeff