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=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_SANE_1 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 7B4BBC47247 for ; Thu, 30 Apr 2020 23:59:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B10EA2072A for ; Thu, 30 Apr 2020 23:59:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B10EA2072A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 269B28E0005; Thu, 30 Apr 2020 19:59:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F2CF8E0001; Thu, 30 Apr 2020 19:59:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E1B28E0005; Thu, 30 Apr 2020 19:59:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0208.hostedemail.com [216.40.44.208]) by kanga.kvack.org (Postfix) with ESMTP id E6D228E0001 for ; Thu, 30 Apr 2020 19:59:39 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9744E8248047 for ; Thu, 30 Apr 2020 23:59:39 +0000 (UTC) X-FDA: 76766191278.30.women40_19fa21a20c403 X-HE-Tag: women40_19fa21a20c403 X-Filterd-Recvd-Size: 3436 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Thu, 30 Apr 2020 23:59:37 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R291e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01355;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0Tx82dB6_1588291170; Received: from US-143344MP.local(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0Tx82dB6_1588291170) by smtp.aliyun-inc.com(127.0.0.1); Fri, 01 May 2020 07:59:33 +0800 Subject: Re: [linux-next PATCH 1/2] mm: khugepaged: add exceed_max_ptes_* helpers To: "Kirill A. Shutemov" Cc: kirill.shutemov@linux.intel.com, hughd@google.com, aarcange@redhat.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <1588200982-69492-1-git-send-email-yang.shi@linux.alibaba.com> <20200430215932.5w5dck3rnieppzqa@box> From: Yang Shi Message-ID: Date: Thu, 30 Apr 2020 16:59:29 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20200430215932.5w5dck3rnieppzqa@box> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US 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 4/30/20 2:59 PM, Kirill A. Shutemov wrote: > On Thu, Apr 30, 2020 at 06:56:21AM +0800, Yang Shi wrote: >> The max_ptes_{swap|none|shared} are defined to tune the behavior of >> khugepaged. The are checked at a couple of places with open coding. >> Replace the opencoding to exceed_pax_ptes_{swap|none_shared} helpers to >> improve the readability. >> >> Cc: Kirill A. Shutemov >> Cc: Hugh Dickins >> Cc: Andrea Arcangeli >> Signed-off-by: Yang Shi >> --- >> mm/khugepaged.c | 27 +++++++++++++++++++++------ >> 1 file changed, 21 insertions(+), 6 deletions(-) >> >> diff --git a/mm/khugepaged.c b/mm/khugepaged.c >> index a02a4c5..0c8d30b 100644 >> --- a/mm/khugepaged.c >> +++ b/mm/khugepaged.c >> @@ -339,6 +339,21 @@ struct attribute_group khugepaged_attr_group = { >> }; >> #endif /* CONFIG_SYSFS */ >> >> +static inline bool exceed_max_ptes_none(unsigned int *nr_ptes) >> +{ >> + return (++(*nr_ptes) > khugepaged_max_ptes_none); >> +} >> + >> +static inline bool exceed_max_ptes_swap(unsigned int *nr_ptes) >> +{ >> + return (++(*nr_ptes) > khugepaged_max_ptes_swap); >> +} >> + >> +static inline bool exceed_max_ptes_shared(unsigned int *nr_ptes) >> +{ >> + return (++(*nr_ptes) > khugepaged_max_ptes_shared); >> +} >> + > Frankly, I find this ugly and confusing. Open-coded version is more > readable to me. I'm sorry you feel that way. I tend to agree that dereference looks not good. The open-coded version is not hard to understand to me either. They are checked at a couple of different places with different variables, i.e. unmapped vs swap, and with different comparisons, > vs <=. I just thought the helpers with unified name started with "exceed_" may make it more self-explained and readable. Anyway this totally depends on taste and I really don't insist on this change. >