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 3E45FEE4993 for ; Sat, 19 Aug 2023 12:15:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71487900007; Sat, 19 Aug 2023 08:15:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69B54900004; Sat, 19 Aug 2023 08:15:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53BE2900007; Sat, 19 Aug 2023 08:15:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3F31F900004 for ; Sat, 19 Aug 2023 08:15:09 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0BB0EB1DBF for ; Sat, 19 Aug 2023 12:15:09 +0000 (UTC) X-FDA: 81140748738.15.FC1BBF5 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf29.hostedemail.com (Postfix) with ESMTP id B024B120004 for ; Sat, 19 Aug 2023 12:15:05 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692447307; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ll0aOCXqlUhk4TpDyU5J7Sf+ikU2L7LrpkkKMt77WAk=; b=ZNb0+KEHadpaqtx1wHrsewe5lhOeeBz+V6sxwiz5sSn925nRgtkc5DcJvwAFFNTq7tmmbg 5fhDeXYKwok033++G8rl6oG8eBFfjTNpcwBqypKLa9i0Pi2Kv89L/Ny/hIWKOni4a3Qdu1 TOdYRrJ8GwgSYoQi2MnFH4Lv3E3/+UY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692447307; a=rsa-sha256; cv=none; b=d9abJeLbGp8G0/eTCdfG4sG/OkSeiHJ9lhsH5c6oOPcBKyDKCUAZ21qL/GZUMs1GozTlNB xKgqamP3ZWjW2OqxzcBJZzBHgQhjs+r/K9ZkDfW4MM1B+2QQ2RdQwpXOkRYmwdh+YKCKWz pAmuSsVJf9EsW45h2PpV4C60OXNElvc= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R481e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0Vq5IL7U_1692447296; Received: from 30.97.48.38(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Vq5IL7U_1692447296) by smtp.aliyun-inc.com; Sat, 19 Aug 2023 20:14:57 +0800 Message-ID: Date: Sat, 19 Aug 2023 20:14:56 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH 6/9] mm/compaction: rename is_via_compact_memory to compaction_with_allocation_order To: Kemeng Shi , linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, mgorman@techsingularity.net, david@redhat.com References: <20230805110711.2975149-1-shikemeng@huaweicloud.com> <20230805110711.2975149-7-shikemeng@huaweicloud.com> <111c3142-e20b-3e3c-f107-cbb64a16c2b0@linux.alibaba.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B024B120004 X-Rspam-User: X-Stat-Signature: wkx9ecchx7mhmxg35iph6gbbojnw7e8a X-Rspamd-Server: rspam01 X-HE-Tag: 1692447305-402769 X-HE-Meta: U2FsdGVkX18q00dh3so06fjCIM4LWRJElOnLHOMvXowT8p4fvPxCDQfIP3JfDhtPTrFVUAumln3o22p+y1mqRt8rhA9ranRYBu8iBW9y8zPlQ9hO5O5EZiP34haErAv1WbRc1br+kdwOl3TMJEt+lVJXZHt5kw7I1GH/ThK35fT2gZq77wJ1L60O5YShMweY9iDuq9CInklWrfryJsckFNQsiTubzyEuRls8qkyaYk74oN+sBaaoRgRHVX2/zZRDL1GMcISd/BqEDQEANxMhdyA58OzmFdvJ8zKgSP6j7yE+oXBMVmLm877OdWUVCW+TwLH1/nycLg4PWwtncr2vszz178ikys24ii1sjbfPX8cLwt13Sqi5+WdEoNZDFKpxKkgoSht5bfybnBFQ1XQfjB0KemDI5GE5GZB8aqtQlSM/YMY5pzQckD4Mh9DSEAHGbH7vo3NbH5sIIgz+DKRjyv0+iu7leM+EHHJZMhXN68g0MtDG0iKBJSl/mIwg5lVW7cr70oDp1eWZr397R3qQkfQmOD+3IhbkR8H7A4S8Zdl+bxHUJyCTjUEmuBs4nv6M4bYSax2E1UHztOMdp6BayG7jzfceGM2HBqOkCW1Ha+uXT2MKkVQSVS/f72xBtbYldHXzB18N+N61gsBzrQ5UFc3bRyZZilyQY6snzMf6OztbNEv1yVRXKL0vNMtC35VDFf01WF1lQVIGiIx/2dZT6sm0YmyxvONo9BqyCPQwbjD2/kK1AOJN0DqaPebsnDs/1Ocdz4lf7R+ha3n5KPQs2AkOahYsPvrydqhPn2btW1uv9jx0uIr9WmefFyjelC2hveuqn9ik04eku9gQZKXfa2lZXCGbnO0JSHaJ78fbDqU0V5+1qGG9YnBSYiTYIk0WjCCLDdpjmbELjreQjDgyRSATAOdkUnoT6msiXEi7eR3XC7uHD51ZBaP/NQwNso5yelzhq4qMHg5pLrzwxbJ y9oRXdtH GQB/DIcfOeWwyE0S29XaSFekIM+KBlJXe/SU1Ty/DsHwRtVGzDL4RQTaMvkRFB6QOt/ZN/dd6yMpy3SxQTtlb+hCXofm3BwitsT20spDJKdwgvpaIamRcmNoo67NSEuvf3SGMM63JdBgJrnGWLhfh3FTm5EQ2igfSsMba2rKxFpd8wWAtzyQ45iS38Q== 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 8/15/2023 8:04 PM, Kemeng Shi wrote: > > > on 8/15/2023 4:58 PM, Baolin Wang wrote: >> >> >> On 8/5/2023 7:07 PM, Kemeng Shi wrote: >>> We have order = -1 via proactive compaction, the is_via_compact_memory is >>> not proper name anymore. >>> As cc->order informs the compaction to satisfy a allocation with that >>> order, so rename it to compaction_with_allocation_order. >>> >>> Signed-off-by: Kemeng Shi >>> --- >>>   mm/compaction.c | 11 +++++------ >>>   1 file changed, 5 insertions(+), 6 deletions(-) >>> >>> diff --git a/mm/compaction.c b/mm/compaction.c >>> index d8416d3dd445..b5a699ed526b 100644 >>> --- a/mm/compaction.c >>> +++ b/mm/compaction.c >>> @@ -2055,12 +2055,11 @@ static isolate_migrate_t isolate_migratepages(struct compact_control *cc) >>>   } >>>     /* >>> - * order == -1 is expected when compacting via >>> - * /proc/sys/vm/compact_memory >>> + * compact to satisfy allocation with target order >>>    */ >>> -static inline bool is_via_compact_memory(int order) >>> +static inline bool compaction_with_allocation_order(int order) >> >> I know naming is hard, but this name is not good enough that can show the compaction mode. But the original one could. >> > Yes, I agree with this, but name and comment of is_via_compact_memory may > mislead reader that order == -1 is equivalent to compaction from > /proc/sys/vm/compact_memory. > Actually, we have several approaches to trigger compaction with order == -1: > 1. via /proc/sys/vm/compact_memory > 2. via /sys/devices/system/node/nodex/compact > 3. via proactive compact They can all be called proactive compaction. > > Instead of indicate compaction is tirggerred by compact_memocy or anything, > order == -1 implies if compaction is triggerrred to meet allocation with high > order and we will stop compaction if allocation with target order will success. IMO, the is_via_compact_memory() function helps people better distinguish the compaction logic we have under direct compaction or kcompactd compaction, while proactive compaction does not concern itself with these details. But compaction_with_allocation_order() will make me just wonder why we should compare with -1. So I don't think this patch is worth it, but as you said above, we can add more comments to make it more clear. >>>   { >>> -    return order == -1; >>> +    return order != -1; >>>   } >>>     /* >>> @@ -2200,7 +2199,7 @@ static enum compact_result __compact_finished(struct compact_control *cc) >>>           goto out; >>>       } >>>   -    if (is_via_compact_memory(cc->order)) >>> +    if (!compaction_with_allocation_order(cc->order)) >>>           return COMPACT_CONTINUE; >>>         /* >>> @@ -2390,7 +2389,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) >>>         cc->migratetype = gfp_migratetype(cc->gfp_mask); >>>   -    if (!is_via_compact_memory(cc->order)) { >>> +    if (compaction_with_allocation_order(cc->order)) { >>>           unsigned long watermark; >>>             /* Allocation can already succeed, nothing to do */ >>