From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D50BC2D0E4 for ; Fri, 20 Nov 2020 23:13:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 511D02242A for ; Fri, 20 Nov 2020 23:13:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="XwzkJGGV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 511D02242A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6803A6B005C; Fri, 20 Nov 2020 18:13:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 632056B005D; Fri, 20 Nov 2020 18:13:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 520DB6B0068; Fri, 20 Nov 2020 18:13:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id 24A386B005C for ; Fri, 20 Nov 2020 18:13:11 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BD0BA181AEF1E for ; Fri, 20 Nov 2020 23:13:10 +0000 (UTC) X-FDA: 77506349340.04.mine32_5f08d692734f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id A2C0580181CC for ; Fri, 20 Nov 2020 23:13:10 +0000 (UTC) X-HE-Tag: mine32_5f08d692734f X-Filterd-Recvd-Size: 2895 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Nov 2020 23:13:10 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A46182240B; Fri, 20 Nov 2020 23:13:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1605913989; bh=kGZ3tY895qvwswmX8ewkKR4DXUjrQEmGUbS1BBPrqao=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=XwzkJGGVKL7FuVt1qEFS7X+RiwM4EE3PuWURqNAeDOPoiHV6zVUJh9Jl9k3+FUX4z rXZAAZQxHYcyfX4+/8AZtT294HTEP5Zkxew1QheWaJLhx+xkCwD4T3xE/4FXWbzie3 RAX3/B7W0MAt35ANy8G7CB1OzKeOr75KHDQblY5Q= Date: Fri, 20 Nov 2020 15:13:07 -0800 From: Andrew Morton To: Alex Shi Cc: Hugh Dickins , Yu Zhao , Vlastimil Babka , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH next] mm/vmscan: __isolate_lru_page_prepare clean up Message-Id: <20201120151307.4d9e3ef092ba01a325db7ce2@linux-foundation.org> In-Reply-To: <1605859413-53864-1-git-send-email-alex.shi@linux.alibaba.com> References: <1605859413-53864-1-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, 20 Nov 2020 16:03:33 +0800 Alex Shi wrote: > The function just return 2 results, so use a 'switch' to deal with its > result is unnecessary, and simplify it to a bool func as Vlastimil > suggested. > > Also removed 'goto' in using by reusing list_move(). > > ... > > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -1540,7 +1540,7 @@ unsigned int reclaim_clean_pages_from_list(struct zone *zone, > */ > int __isolate_lru_page_prepare(struct page *page, isolate_mode_t mode) > { > - int ret = -EBUSY; > + int ret = false; > > /* Only take pages on the LRU. */ > if (!PageLRU(page)) > @@ -1590,7 +1590,7 @@ int __isolate_lru_page_prepare(struct page *page, isolate_mode_t mode) > if ((mode & ISOLATE_UNMAPPED) && page_mapped(page)) > return ret; > > - return 0; > + return true; > } The resulting __isolate_lru_page_prepare() is rather unpleasing. - Why return an int and not a bool? - `int ret = false' is a big hint that `ret' should have bool type! - Why not just remove `ret' and do `return false' in all those `return ret' places? - The __isolate_lru_page_prepare() kerneldoc still says "returns 0 on success, -ve errno on failure".