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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D0C7ECAAA1 for ; Thu, 15 Sep 2022 21:45:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 92ED28D0001; Thu, 15 Sep 2022 17:45:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B6B36B0072; Thu, 15 Sep 2022 17:45:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 730C88D0001; Thu, 15 Sep 2022 17:45:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5CD5C6B0071 for ; Thu, 15 Sep 2022 17:45:08 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 32BBC1A0113 for ; Thu, 15 Sep 2022 21:45:08 +0000 (UTC) X-FDA: 79915650696.26.587FFF6 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf04.hostedemail.com (Postfix) with ESMTP id B085A400A5 for ; Thu, 15 Sep 2022 21:45:06 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1CDFBB82234; Thu, 15 Sep 2022 21:45:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACEB0C433D6; Thu, 15 Sep 2022 21:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1663278303; bh=ondPqiIv00SaqFFzETnfFTIZrNHScOlUmailF0Bt7bw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=a6TVrhndKjuiPGGpUhhVhL4UpbvbyuZ0ChBABYaCZXpP1Z78KUpwnaF9yr9WZIfgW l8S9OpWLLjW7M9JSxjlZINmniw0IGjFXU5Evg6WGM57KgzlqRO+rIXH1jQpoPnx/zp 0iOdlYxg8Yvj7TL4FOHU93DA7OZybPTdRJDsDFj8= Date: Thu, 15 Sep 2022 14:45:02 -0700 From: Andrew Morton To: "zhaoyang.huang" Cc: Zhaoyang Huang , , , Subject: Re: [PATCH] mm: change the type to bool for page_has_xxx's val Message-Id: <20220915144502.31e7241c6144f23ce197428b@linux-foundation.org> In-Reply-To: <1663210600-29258-1-git-send-email-zhaoyang.huang@unisoc.com> References: <1663210600-29258-1-git-send-email-zhaoyang.huang@unisoc.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663278306; a=rsa-sha256; cv=none; b=ieWUavi70HPaMyxWx9ZelpJSs5NTc1nEymWt5RgriT33tfBKha7dNpmzYU18/wInhOI5d1 etP6jOFg2PBbNZPQNHDoIPhXEIdJzlp/TWaSq2zuUh8c0WLJlc3zE2JQXvR+rCJsukg4Xz ten9vYoyiOopacJH2twFafIyHUsEDjA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=a6TVrhnd; spf=pass (imf04.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663278306; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7hQBCCiw59Ps/HasxnY28Rvvk8COLsLR8PthQWFCWOA=; b=DWZWosv+iNJWVVjt129dC9EkRk8JdRUSnw621jlvGF/n8qGOGKDxIswUdEg0ULsQjgjW2u 1A5NJx50gKUz+Sj32trytsxZFG1g5TGjn7x8oa/iD+YMrWjftp9x7WzQ+ehQb/7BinasON k7V1aZegX56XFBevBgX12CKrDQUGSUY= X-Rspam-User: Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=a6TVrhnd; spf=pass (imf04.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam03 X-Stat-Signature: dagbjp7wwid6mmwfaus5ew9x4zpywogu X-Rspamd-Queue-Id: B085A400A5 X-HE-Tag: 1663278306-210505 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 Thu, 15 Sep 2022 10:56:40 +0800 "zhaoyang.huang" wrote: > From: Zhaoyang Huang > > It is proper to return bool value for such functions > > Signed-off-by: Zhaoyang Huang > --- > include/linux/page-flags.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h > index e66f7aa..9a46c8b 100644 > --- a/include/linux/page-flags.h > +++ b/include/linux/page-flags.h > @@ -946,9 +946,9 @@ static inline bool is_page_hwpoison(struct page *page) > #define PageType(page, flag) \ > ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) > > -static inline int page_has_type(struct page *page) > +static inline bool page_has_type(struct page *page) > { > - return (int)page->page_type < PAGE_MAPCOUNT_RESERVE; > + return !!((int)page->page_type < PAGE_MAPCOUNT_RESERVE); Much nicer to simply do this: return page->page_type < PAGE_MAPCOUNT_RESERVE; > } > > #define PAGE_TYPE_OPS(uname, lname) \ > @@ -1081,7 +1081,7 @@ static __always_inline void __ClearPageAnonExclusive(struct page *page) > * Determine if a page has private stuff, indicating that release routines > * should be invoked upon it. > */ > -static inline int page_has_private(struct page *page) > +static inline bool page_has_private(struct page *page) > { > return !!(page->flags & PAGE_FLAGS_PRIVATE); > } Maybe. This might cause the compiler to emit more code, to convert the integer to a bool having value 0 or 1. It would do so if the code was uninlined. But given that it's inlined, the compiler hopefully has the brains to avoid doing that and to test the integer directly. Please check this - the above change shouldn't increase the .o file's text section size.