Message ID | cover.1676382188.git.baolin.wang@linux.alibaba.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2991941wrn; Tue, 14 Feb 2023 06:06:52 -0800 (PST) X-Google-Smtp-Source: AK7set93Kug3IDxX8rzaD57yfmj9sCfEH/EYwtms8LUe7WOYvA+D81sk8Kr1AyyxS6v/VuojiY8R X-Received: by 2002:a17:90b:1b41:b0:233:f786:35ca with SMTP id nv1-20020a17090b1b4100b00233f78635camr2372802pjb.35.1676383612299; Tue, 14 Feb 2023 06:06:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676383612; cv=none; d=google.com; s=arc-20160816; b=R+6EdetzhV7Nv/BLIyeV+WStsEJSvSbwO+jSZ23qjFYAYE8ujwboGMdNHRXu3BfcH2 69/5LWp747mYH/T95jQFRC/EfrJt6DttdlfFwVaeoV715wu4SPYi1jsuH8Xxe55rmjTX RW42Qx9h1AeDjZA77DQgD9rEFR4yccit2CwzD3S5gACQ2dfRconf5qdQKWDF3pWa+7T2 taROQrNGz6AoSgX3UoNzruZjBCuDdSbnPsjKJGU4O389uI7bgwM/eQPCn4m7JQ4hk6lo 2yEQYdnh9sn6CjhNhvln09uRlcUYlkgCw9hhX1k0ePSI5gnxUXD4/EmRIQSNbkUZQTTq vXvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=US9QS86tQGgAytpKxRWwsrL4TMXq7Zh7043oglz6QWY=; b=Y9xfLCV5VsoHlYIQnktRZbLKYCc02SDDwW0/lAuRPS5MI4/F4smr6cBMBvp6Du4/eQ cSoE8dvaFgP/qtEFlHOQCrKTSyyOkVboi3NEvSNNv1GYksHEKnirLTsfx2WwdB8j31wa nM4eOetYw64C0CNUwG79+JRKNDXPtFVSWe1aM6cBx/jP9uAjBkKsRuXe3y7J55oMizrp Uce6O1csYIr+Y+yGbHd2FaLDCupl4laAwyIMRsHx2P1Worpn+PNmot03ZjFieUiZnVKs 70zp6s22G9RsKY/fZAg+vJsmGuvjw8EfFL7Giv40wT0zSVF0s8K3czRZpvhT1gtiqBLV yHig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x9-20020a17090aca0900b00233abe49bd1si12129985pjt.109.2023.02.14.06.06.39; Tue, 14 Feb 2023 06:06:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233055AbjBNOAC (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Tue, 14 Feb 2023 09:00:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233132AbjBNN74 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Feb 2023 08:59:56 -0500 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04F6518C; Tue, 14 Feb 2023 05:59:45 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0VbgTJ0R_1676383178; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VbgTJ0R_1676383178) by smtp.aliyun-inc.com; Tue, 14 Feb 2023 21:59:39 +0800 From: Baolin Wang <baolin.wang@linux.alibaba.com> To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, sj@kernel.org, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, naoya.horiguchi@nec.com, linmiaohe@huawei.com, david@redhat.com, osalvador@suse.de, mike.kravetz@oracle.com, willy@infradead.org, baolin.wang@linux.alibaba.com, damon@lists.linux.dev, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/4] Change the return value for page isolation functions Date: Tue, 14 Feb 2023 21:59:28 +0800 Message-Id: <cover.1676382188.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757815622690519107?= X-GMAIL-MSGID: =?utf-8?q?1757815622690519107?= |
Series |
Change the return value for page isolation functions
|
|
Message
Baolin Wang
Feb. 14, 2023, 1:59 p.m. UTC
Now the page isolation functions did not return a boolean to indicate success or not, instead it will return a negative error when failed to isolate a page. So below code used in most places seem a boolean success/failure thing, which can confuse people whether the isolation is successful. if (folio_isolate_lru(folio)) continue; Moreover the page isolation functions only return 0 or -EBUSY, and most users did not care about the negative error except for few users, thus we can convert all page isolation functions to return a boolean value, which can remove the confusion to make code more clear. No functional changes intended in this patch series. Changes from v1: - Convert all isolation functions to return bool. Baolin Wang (4): mm: change to return bool for folio_isolate_lru() mm: change to return bool for isolate_lru_page() mm: hugetlb: change to return bool for isolate_hugetlb() mm: change to return bool for isolate_movable_page() include/linux/hugetlb.h | 6 +++--- include/linux/migrate.h | 6 +++--- mm/compaction.c | 2 +- mm/damon/paddr.c | 2 +- mm/folio-compat.c | 4 ++-- mm/gup.c | 2 +- mm/hugetlb.c | 12 ++++++++---- mm/internal.h | 4 ++-- mm/khugepaged.c | 4 ++-- mm/madvise.c | 4 ++-- mm/memcontrol.c | 4 ++-- mm/memory-failure.c | 10 +++++----- mm/memory_hotplug.c | 2 +- mm/mempolicy.c | 4 ++-- mm/migrate.c | 17 ++++++++++------- mm/migrate_device.c | 2 +- mm/vmscan.c | 10 +++++----- 17 files changed, 51 insertions(+), 44 deletions(-)
Comments
On 14.02.23 14:59, Baolin Wang wrote: > Now the page isolation functions did not return a boolean to indicate > success or not, instead it will return a negative error when failed > to isolate a page. So below code used in most places seem a boolean > success/failure thing, which can confuse people whether the isolation > is successful. > > if (folio_isolate_lru(folio)) > continue; > > Moreover the page isolation functions only return 0 or -EBUSY, and > most users did not care about the negative error except for few users, > thus we can convert all page isolation functions to return a boolean > value, which can remove the confusion to make code more clear. > > No functional changes intended in this patch series. > > Changes from v1: > - Convert all isolation functions to return bool. Acked-by: David Hildenbrand <david@redhat.com> Although it's controversial if if (!ret) ret = -EBUSY; else ret = 0; is really appealing to the readers eye :) ret = ret ? 0 : -EBUSY; It's still confusing. would be better as ret = isolated ? 0 : -EBUSY; IOW, not reusing the "int ret" variable.
On 2/15/2023 1:52 AM, David Hildenbrand wrote: > On 14.02.23 14:59, Baolin Wang wrote: >> Now the page isolation functions did not return a boolean to indicate >> success or not, instead it will return a negative error when failed >> to isolate a page. So below code used in most places seem a boolean >> success/failure thing, which can confuse people whether the isolation >> is successful. >> >> if (folio_isolate_lru(folio)) >> continue; >> >> Moreover the page isolation functions only return 0 or -EBUSY, and >> most users did not care about the negative error except for few users, >> thus we can convert all page isolation functions to return a boolean >> value, which can remove the confusion to make code more clear. >> >> No functional changes intended in this patch series. >> >> Changes from v1: >> - Convert all isolation functions to return bool. > > Acked-by: David Hildenbrand <david@redhat.com> Thanks. > > Although it's controversial if > > if (!ret) > ret = -EBUSY; > else > ret = 0; > > is really appealing to the readers eye :) > > ret = ret ? 0 : -EBUSY; > > It's still confusing. > > would be better as > > ret = isolated ? 0 : -EBUSY; > > IOW, not reusing the "int ret" variable. Yes, pretty clear. Will do in next version.