From patchwork Wed Sep 13 09:51:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 138725 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp968604vqx; Wed, 13 Sep 2023 02:54:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDDCwAb2NrhSjWHU/+MjpK0kNrkxyEGloDtCH9bRfGJ2Cid73HF4/NREDSx2A2EXg8QZsv X-Received: by 2002:a05:6a00:230b:b0:68e:30db:ee43 with SMTP id h11-20020a056a00230b00b0068e30dbee43mr2595333pfh.21.1694598883857; Wed, 13 Sep 2023 02:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694598883; cv=none; d=google.com; s=arc-20160816; b=Eg6QTIbs1R2AivwCFcvCwFUcowD7bWwubXV4F/Syvtb32SVs9fg89uTv3wGh5EG/dk RivZT8MQnVHGFiokm+Wmdg/QUwmm6F3rau1CbZgiZ2cSCKvzmHx6+eTQuD+JwfQYg6Vt zDGxA2jfMoHxNxnTfy6iUYxIyx4mzb/+fckl81dv2FxsfzrX60auFDvpD11YPkKEnoUX uc3IAEz0T/Z47BdJDf+WQ6YxYdPFkSr3c8dHW/wNr5ukD05cMIuoYudtqLoz0K8OzsHH EApDqbF24ic9eXhZD2pjutmO4bfAUNv7mhZtKmG0AjZwt3FuzCsDKoiblzTnXj1RB0FN Nnmg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=DCfJIYv9BZvAD508DaHGVzJ85GuKmA46MB8WO109kEY=; fh=Je6qNyAM729b1goCtB6PkBk+yQrlQCIjJMRY6BFgKTo=; b=XvRoOH7WITTxzlSLmztH+0dVQ23R//Gk9hCrKdPzM3TWjhueQVmRbrTGEKLeTPM+lJ GekYlJHOnzhrZ46mMH/HtbVCCqbCpMN8ztcauDmOxzlksnDtOm80pFcrHf9zfvZpD92M 9sQdkWRSRn06CEAaNnxLidIXG5767cIENTS9Ls3eCC7vuu9AWPj8krPorTttmf2nozWP r/U2mSbjXhKGZ/wZSEVki7upG8Pbx1lle9HsgsIMLb5s/U+kETOtrmYCKJrzl5qTiuZB wofC0JjAoKuC+CqEyVSIW5EHppao0C9mabm431rkiPDCl2Xdl4HR9L3Re3A+6Cm6dV4M 0ZSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bd34-20020a056a0027a200b0068e3958a139si4802998pfb.186.2023.09.13.02.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 02:54:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0606581BAA5B; Wed, 13 Sep 2023 02:52:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239599AbjIMJwX (ORCPT + 36 others); Wed, 13 Sep 2023 05:52:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239516AbjIMJwI (ORCPT ); Wed, 13 Sep 2023 05:52:08 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55B3219BB for ; Wed, 13 Sep 2023 02:52:04 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rlwdl20fPzVkfZ; Wed, 13 Sep 2023 17:49:15 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:52:02 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 8/8] mm: migrate: remove isolated variable in add_page_for_migration() Date: Wed, 13 Sep 2023 17:51:31 +0800 Message-ID: <20230913095131.2426871-9-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:52:57 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776915718905205201 X-GMAIL-MSGID: 1776915718905205201 Directly check the return of isolate_hugetlb() and folio_isolate_lru() to remove isolated variable, also setup err = -EBUSY in advance before isolation, and update err only when successfully queued for migration, which could help us to unify and simplify code a bit. Reviewed-by: Zi Yan Signed-off-by: Kefeng Wang --- mm/migrate.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 7b07c97f5a6f..a5d739603458 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2059,7 +2059,6 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, struct page *page; struct folio *folio; int err; - bool isolated; mmap_read_lock(mm); addr = (unsigned long)untagged_addr_remote(mm, p); @@ -2092,15 +2091,13 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, if (page_mapcount(page) > 1 && !migrate_all) goto out_putfolio; + err = -EBUSY; if (folio_test_hugetlb(folio)) { - isolated = isolate_hugetlb(folio, pagelist); - err = isolated ? 1 : -EBUSY; + if (isolate_hugetlb(folio, pagelist)) + err = 1; } else { - isolated = folio_isolate_lru(folio); - if (!isolated) { - err = -EBUSY; + if (!folio_isolate_lru(folio)) goto out_putfolio; - } err = 1; list_add_tail(&folio->lru, pagelist);