Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp86801ybz; Thu, 30 Apr 2020 17:01:57 -0700 (PDT) X-Google-Smtp-Source: APiQypIy4PXI8zuyTTNMFn4dt13cXg6JsI6aqKApN/vpDUmrV7RlOtmUtUByrwnzZnRT3/uGZFw+ X-Received: by 2002:a17:906:1ccb:: with SMTP id i11mr904342ejh.101.1588291317094; Thu, 30 Apr 2020 17:01:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588291317; cv=none; d=google.com; s=arc-20160816; b=sWW5jmdJic6rzmSRI9ICENAmfxuKPCX96Vo2DifgPjKNp8O8R2EbKqvaMdW0eLZCdM bL8MYCkhIKqfcg3SmYLn4FZULvPb2A0r2MggPmWCHYhe+zUipPG61pvUW89/6CqHV9Uq iaLKKqJv41+/w7ATIwe/+VN6ZJi4u5Em+rS/4mBK/paHtTqYsui7Y0d+iip1U/w6lnBC fz37ShuVsKsBkNhz1GvjOqtAZUyGmLgAIWGkxKSZpdI/G/KEg1tAi+4CRvQZ5zTYk0Ra bku17RTmaxfT9/cSlsbrwnuUGc3qMl3hGKCs8VQcomylEFmpHO2NDX7+m8l4ooh5fn1P VKpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=T6jIQMzXf81b9QYVAvBg7cTCuNq9JpYhkgSvAc74Jus=; b=iW2FxqPstdpmJyDyWCk9SM6ZonsS+kiqTlhiqWTNJEwQ8dxf4KU+W86uYxExwjnX5A CJyE/csey6k1y+IenGCdBf0SComA1oBRQsGT6eU29zoWgBj6IfnFa8HNTDccIWiRicJr +9poiK5F+S0QImDlNwmv5OdNFmR8HgQZ4+9CCBV/xAcAFXmbYyy5rYjRnYOFc6H/CNgW QY6fEmDkYIIXgMjsENodXwefb0ZwrSute/sBMsYXNLbbtx0wb3h27eHZoFOopHN7v5Y9 LVaeyhLPs2q1t9tfNtXPVxnXao/W7Szam0sTzAR1TBUC2V4xbXga0uVuzG9curNorcKQ dx2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si797832ejh.219.2020.04.30.17.01.27; Thu, 30 Apr 2020 17:01:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727027AbgD3X7h (ORCPT + 99 others); Thu, 30 Apr 2020 19:59:37 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:50239 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726384AbgD3X7h (ORCPT ); Thu, 30 Apr 2020 19:59:37 -0400 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. >