From patchwork Thu Oct 10 13:40:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28Intel=29?= X-Patchwork-Id: 11183633 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA7CF1709 for ; Thu, 10 Oct 2019 13:41:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 77FF02067B for ; Thu, 10 Oct 2019 13:41:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=shipmail.org header.i=@shipmail.org header.b="ijWXaZYo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77FF02067B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shipmail.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BA3176B0006; Thu, 10 Oct 2019 09:41:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B79636B0007; Thu, 10 Oct 2019 09:41:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CE8A8E0003; Thu, 10 Oct 2019 09:41:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0064.hostedemail.com [216.40.44.64]) by kanga.kvack.org (Postfix) with ESMTP id 733A46B0006 for ; Thu, 10 Oct 2019 09:41:22 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 17E9D7588 for ; Thu, 10 Oct 2019 13:41:22 +0000 (UTC) X-FDA: 76027986804.05.crook93_8036115e58144 X-Spam-Summary: 2,0,0,5d8c4971e1905e33,d41d8cd98f00b204,thomas_os@shipmail.org,:linux-kernel@vger.kernel.org::torvalds@linux-foundation.org:kirill@shutemov.name:thellstrom@vmware.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1311:1314:1345:1359:1437:1515:1535:1542:1676:1711:1730:1747:1777:1792:2393:2559:2562:2910:3138:3139:3140:3141:3142:3354:3865:3867:3868:3871:3874:4321:4605:5007:6119:6120:6121:6261:6653:7576:7875:10004:11026:11473:11658:11914:12043:12048:12297:12438:12517:12519:12555:12679:12895:13161:13229:13255:13894:14093:14096:14181:14721:21080:21212:21451:21627:21740:21939:30012:30054,0,RBL:213.80.101.70:@shipmail.org:.lbl8.mailshell.net-62.2.203.100 64.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: crook93_8036115e58144 X-Filterd-Recvd-Size: 5252 Received: from ste-pvt-msa1.bahnhof.se (ste-pvt-msa1.bahnhof.se [213.80.101.70]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Oct 2019 13:41:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTP id 5038F3F662; Thu, 10 Oct 2019 15:41:19 +0200 (CEST) Authentication-Results: ste-pvt-msa1.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=ijWXaZYo; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from ste-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (ste-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JuFPudYhk_3z; Thu, 10 Oct 2019 15:41:18 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id EBF0D3F247; Thu, 10 Oct 2019 15:41:17 +0200 (CEST) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 2C952360ED5; Thu, 10 Oct 2019 15:41:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1570714877; bh=xEUu8V1jmdy0b1JnfsdE1ixgai5iPm/a0UL1Js6USpk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ijWXaZYo+2T/KF/TFThEJ4/Jb8vCSvNjD316eFCovtyF5dIhD6is1nn8Kn78Yp1wl 109pQPDHWw2KQATIc41ioJqlpOP16P7BQjGrKD72PtUYMLh1D9cydzTUygDh0D4Xbp cSmgxlrMIlSAK3nmcoPyIrQVjCSCd17RHCyvyuIs= From: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28VMware=29?= To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, torvalds@linux-foundation.org, kirill@shutemov.name Cc: Thomas Hellstrom Subject: [RFC PATCH 1/4] mm: Have the mempolicy pagewalk to avoid positive callback return codes Date: Thu, 10 Oct 2019 15:40:55 +0200 Message-Id: <20191010134058.11949-2-thomas_os@shipmail.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191010134058.11949-1-thomas_os@shipmail.org> References: <20191010134058.11949-1-thomas_os@shipmail.org> MIME-Version: 1.0 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: From: Linus Torvalds The pagewalk code is being reworked to have positive callback return codes do walk control. Avoid using positive return codes: "1" is replaced by "-EBUSY". Co-developed-by: Thomas Hellstrom Signed-off-by: Thomas Hellstrom --- mm/mempolicy.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 4ae967bcf954..df34c7498c27 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -482,8 +482,8 @@ static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, * * queue_pages_pte_range() has three possible return values: * 0 - pages are placed on the right node or queued successfully. - * 1 - there is unmovable page, and MPOL_MF_MOVE* & MPOL_MF_STRICT were - * specified. + * -EBUSY - there is unmovable page, and MPOL_MF_MOVE* & MPOL_MF_STRICT were + * specified. * -EIO - only MPOL_MF_STRICT was specified and an existing page was already * on a node that does not follow the policy. */ @@ -503,7 +503,7 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr, if (ptl) { ret = queue_pages_pmd(pmd, ptl, addr, end, walk); if (ret != 2) - return ret; + return (ret == 1) ? -EBUSY : ret; } /* THP was split, fall through to pte walk */ @@ -546,7 +546,7 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr, cond_resched(); if (has_unmovable) - return 1; + return -EBUSY; return addr != end ? -EIO : 0; } @@ -669,9 +669,9 @@ static const struct mm_walk_ops queue_pages_walk_ops = { * passed via @private. * * queue_pages_range() has three possible return values: - * 1 - there is unmovable page, but MPOL_MF_MOVE* & MPOL_MF_STRICT were - * specified. * 0 - queue pages successfully or no misplaced page. + * -EBUSY - there is unmovable page, but MPOL_MF_MOVE* & MPOL_MF_STRICT were + * specified. * -EIO - there is misplaced page and only MPOL_MF_STRICT was specified. */ static int @@ -1285,7 +1285,7 @@ static long do_mbind(unsigned long start, unsigned long len, ret = queue_pages_range(mm, start, end, nmask, flags | MPOL_MF_INVERT, &pagelist); - if (ret < 0) { + if (ret < 0 && ret != -EBUSY) { err = -EIO; goto up_out; } @@ -1303,7 +1303,7 @@ static long do_mbind(unsigned long start, unsigned long len, putback_movable_pages(&pagelist); } - if ((ret > 0) || (nr_failed && (flags & MPOL_MF_STRICT))) + if ((ret < 0) || (nr_failed && (flags & MPOL_MF_STRICT))) err = -EIO; } else putback_movable_pages(&pagelist); From patchwork Thu Oct 10 13:40:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28Intel=29?= X-Patchwork-Id: 11183635 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BF6D112B for ; Thu, 10 Oct 2019 13:41:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1924021D82 for ; Thu, 10 Oct 2019 13:41:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=shipmail.org header.i=@shipmail.org header.b="D32cRh/8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1924021D82 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shipmail.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 71CFB6B0008; Thu, 10 Oct 2019 09:41:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6975F8E0003; Thu, 10 Oct 2019 09:41:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 516906B000A; Thu, 10 Oct 2019 09:41:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0210.hostedemail.com [216.40.44.210]) by kanga.kvack.org (Postfix) with ESMTP id 219D16B0007 for ; Thu, 10 Oct 2019 09:41:26 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id BCD98181AC9AE for ; Thu, 10 Oct 2019 13:41:25 +0000 (UTC) X-FDA: 76027986930.10.cap91_80d691834da14 X-Spam-Summary: 2,0,0,8a65017fc84de675,d41d8cd98f00b204,thomas_os@shipmail.org,:linux-kernel@vger.kernel.org::torvalds@linux-foundation.org:kirill@shutemov.name:thellstrom@vmware.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1311:1314:1345:1359:1437:1515:1534:1539:1676:1711:1714:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3350:3865:3867:3871:4321:5007:6120:6261:6653:7576:10004:11026:11473:11658:11914:12048:12296:12297:12517:12519:12555:12679:12895:13069:13161:13229:13255:13311:13357:13894:14096:14181:14384:14721:21080:21212:21451:21627:21740:30012:30054,0,RBL:213.80.101.71:@shipmail.org:.lbl8.mailshell.net-62.2.203.100 64.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: cap91_80d691834da14 X-Filterd-Recvd-Size: 3398 Received: from ste-pvt-msa2.bahnhof.se (ste-pvt-msa2.bahnhof.se [213.80.101.71]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Oct 2019 13:41:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 1BDD93F218; Thu, 10 Oct 2019 15:41:19 +0200 (CEST) Authentication-Results: ste-pvt-msa2.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=D32cRh/8; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Authentication-Results: ste-ftg-msa2.bahnhof.se (amavisd-new); dkim=pass (1024-bit key) header.d=shipmail.org Received: from ste-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (ste-ftg-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J7j8NN9xYygG; Thu, 10 Oct 2019 15:41:17 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 7F5343F5BA; Thu, 10 Oct 2019 15:41:17 +0200 (CEST) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 4E2D636105C; Thu, 10 Oct 2019 15:41:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1570714877; bh=WNkn6DKxrc1ZFUEVaoGHRMxt8C+XYlS9MSYyqtJVrQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D32cRh/8yzGyBnNXzo5kC1wRWfBHZhjN7bh56q7wTX8quGWXIWNK3PKaBKbSYpelQ qAyAKiotKQAruoUnITQIrRqIfNt13qlj3lsJt4dIIAFy4HgFGxt7qK8QwOUP0Ge803 bxebV8E7Upmqi6PUwLtnl6wA3ZklU8oN4CJxDhIU= From: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28VMware=29?= To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, torvalds@linux-foundation.org, kirill@shutemov.name Cc: Thomas Hellstrom Subject: [RFC PATCH 2/4] fs: task_mmu: Have the pagewalk avoid positive callback return codes Date: Thu, 10 Oct 2019 15:40:56 +0200 Message-Id: <20191010134058.11949-3-thomas_os@shipmail.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191010134058.11949-1-thomas_os@shipmail.org> References: <20191010134058.11949-1-thomas_os@shipmail.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.004728, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Thomas Hellstrom The pagewalk code is being reworked to have positive callback return codes mean "walk control". Avoid using positive return codes: "1" is replaced by "-ENOBUFS". Signed-off-by: Thomas Hellstrom --- fs/proc/task_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 9442631fd4af..ef11969d9ba1 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1265,7 +1265,7 @@ struct pagemapread { #define PM_SWAP BIT_ULL(62) #define PM_PRESENT BIT_ULL(63) -#define PM_END_OF_BUFFER 1 +#define PM_END_OF_BUFFER (-ENOBUFS) static inline pagemap_entry_t make_pme(u64 frame, u64 flags) { From patchwork Thu Oct 10 13:40:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28Intel=29?= X-Patchwork-Id: 11183637 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D8BA112B for ; Thu, 10 Oct 2019 13:41:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CED2A2067B for ; Thu, 10 Oct 2019 13:41:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=shipmail.org header.i=@shipmail.org header.b="XJ9AzqJr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CED2A2067B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shipmail.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C8D346B0007; Thu, 10 Oct 2019 09:41:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C3C6E8E0003; Thu, 10 Oct 2019 09:41:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB9FB6B000C; Thu, 10 Oct 2019 09:41:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0061.hostedemail.com [216.40.44.61]) by kanga.kvack.org (Postfix) with ESMTP id 70E0A6B0007 for ; Thu, 10 Oct 2019 09:41:26 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 02D87180AD804 for ; Thu, 10 Oct 2019 13:41:26 +0000 (UTC) X-FDA: 76027986972.06.front45_80d9047c9993d X-Spam-Summary: 2,0,0,3895400030604bb2,d41d8cd98f00b204,thomas_os@shipmail.org,:linux-kernel@vger.kernel.org::torvalds@linux-foundation.org:kirill@shutemov.name:thellstrom@vmware.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1311:1314:1345:1359:1437:1515:1534:1542:1676:1711:1730:1747:1777:1792:2393:2559:2562:2898:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3871:3872:3873:3874:4321:4398:4605:5007:6120:6261:6653:7576:10004:11026:11473:11658:11914:12043:12048:12296:12297:12517:12519:12555:12679:12895:12986:13255:13894:14096:14181:14721:21080:21212:21451:21627:21939:30003:30012:30051:30054:30070,0,RBL:79.136.2.41:@shipmail.org:.lbl8.mailshell.net-62.2.203.100 64.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: front45_80d9047c9993d X-Filterd-Recvd-Size: 4535 Received: from pio-pvt-msa2.bahnhof.se (pio-pvt-msa2.bahnhof.se [79.136.2.41]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Oct 2019 13:41:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id A5BEB3F32B; Thu, 10 Oct 2019 15:41:18 +0200 (CEST) Authentication-Results: pio-pvt-msa2.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=XJ9AzqJr; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from pio-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PvCIW3Nwcj92; Thu, 10 Oct 2019 15:41:17 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 9D2A63F260; Thu, 10 Oct 2019 15:41:17 +0200 (CEST) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 658F43610CE; Thu, 10 Oct 2019 15:41:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1570714877; bh=I43d2BTecvoJPXAN1AxjOTn1uEK1Ks5L6V9rF+kVywU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XJ9AzqJrkAVMR4RNVKFniF4BTgPqdLa+jiit+c4NumrcPH91KNui0QgSnvzaT0h1b Enxl+sJfziYIHP/L28Sv0vj8uxgmRM2AahsWxj9JoVctrzhjNVkJE+FO9HLi2E7dhY lXbUSY8Vh8b7YI3Shl123a996WCXuLCV5pRMl4V0= From: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28VMware=29?= To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, torvalds@linux-foundation.org, kirill@shutemov.name Cc: Thomas Hellstrom Subject: [RFC PATCH 3/4] mm: pagewalk: Disallow user positive callback return values and use them for walk control Date: Thu, 10 Oct 2019 15:40:57 +0200 Message-Id: <20191010134058.11949-4-thomas_os@shipmail.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191010134058.11949-1-thomas_os@shipmail.org> References: <20191010134058.11949-1-thomas_os@shipmail.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Linus Torvalds When we have both a pmd_entry() and a pte_entry() callback, in some siutaions it is desirable not to traverse the pte level. Reserve positive callback return values for walk control and define a return value PAGE_WALK_CONTINUE that means skip lower level traversal and continue the walk. Co-developed-by: Thomas Hellstrom Signed-off-by: Thomas Hellstrom --- include/linux/pagewalk.h | 6 ++++++ mm/pagewalk.c | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/linux/pagewalk.h b/include/linux/pagewalk.h index 6ec82e92c87f..d9e5d1927315 100644 --- a/include/linux/pagewalk.h +++ b/include/linux/pagewalk.h @@ -4,6 +4,12 @@ #include +/* + * pmd_entry() Return code meaning skip to next entry. + * Don't look for lower levels + */ +#define PAGE_WALK_CONTINUE 1 + struct mm_walk; /** diff --git a/mm/pagewalk.c b/mm/pagewalk.c index ea0b9e606ad1..d2483d432fda 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c @@ -52,8 +52,12 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, */ if (ops->pmd_entry) err = ops->pmd_entry(pmd, addr, next, walk); - if (err) + if (err < 0) break; + if (err == PAGE_WALK_CONTINUE) { + err = 0; + continue; + } /* * Check this here so we only break down trans_huge @@ -291,8 +295,7 @@ static int __walk_page_range(unsigned long start, unsigned long end, * * - 0 : succeeded to handle the current entry, and if you don't reach the * end address yet, continue to walk. - * - >0 : succeeded to handle the current entry, and return to the caller - * with caller specific value. + * - >0 : Reserved for walk control. Use only PAGE_WALK_XX values. * - <0 : failed to handle the current entry, and return to the caller * with error code. * From patchwork Thu Oct 10 13:40:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28Intel=29?= X-Patchwork-Id: 11183631 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E875112B for ; Thu, 10 Oct 2019 13:41:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2B81220B7C for ; Thu, 10 Oct 2019 13:41:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=shipmail.org header.i=@shipmail.org header.b="X+y/07DC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B81220B7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shipmail.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4EC6D6B0005; Thu, 10 Oct 2019 09:41:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 474308E0003; Thu, 10 Oct 2019 09:41:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3893F6B0007; Thu, 10 Oct 2019 09:41:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0019.hostedemail.com [216.40.44.19]) by kanga.kvack.org (Postfix) with ESMTP id 1A40D6B0005 for ; Thu, 10 Oct 2019 09:41:22 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id BE63782437D7 for ; Thu, 10 Oct 2019 13:41:21 +0000 (UTC) X-FDA: 76027986762.07.shame93_80390aea6d552 X-Spam-Summary: 10,1,0,ec16989477915bc3,d41d8cd98f00b204,thomas_os@shipmail.org,:linux-kernel@vger.kernel.org::torvalds@linux-foundation.org:kirill@shutemov.name:thellstrom@vmware.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1311:1314:1345:1359:1437:1515:1534:1541:1676:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3868:3874:4250:4321:4605:5007:6117:6120:6261:6653:7576:7901:7903:10007:11026:11232:11473:11658:11914:12048:12114:12296:12297:12438:12517:12519:12555:12679:12895:12986:13069:13311:13357:13894:14096:14181:14384:14721:21080:21451:21627:30054,0,RBL:79.136.2.40:@shipmail.org:.lbl8.mailshell.net-62.2.203.100 64.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:1:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: shame93_80390aea6d552 X-Filterd-Recvd-Size: 3992 Received: from pio-pvt-msa1.bahnhof.se (pio-pvt-msa1.bahnhof.se [79.136.2.40]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Oct 2019 13:41:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTP id 590523F598; Thu, 10 Oct 2019 15:41:19 +0200 (CEST) Authentication-Results: pio-pvt-msa1.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b="X+y/07DC"; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from pio-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wl0QoKF-zCWb; Thu, 10 Oct 2019 15:41:18 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id E9AE93F58C; Thu, 10 Oct 2019 15:41:17 +0200 (CEST) Received: from localhost.localdomain.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 7D18E36016C; Thu, 10 Oct 2019 15:41:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1570714877; bh=PbaGuh2AWzgR/QobTlpM3PYlJJowJXX6P7DMUtKFhwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X+y/07DCYti5qO8GpDRx7v6qmNnd1qY4d+px/dYzGwT/xp4RIn7PYIWspQ0IqSV5k T4E+F8ZdO3cy4VxhktQQac/74KLcQaOPnohGoQXODFsAYS7v5WSu25HzRX1Bxm9r4R qTMpmKo7XQMCwVieRVRZ2yPsEEPBimGYbC3+eQ7M= From: =?utf-8?q?Thomas_Hellstr=C3=B6m_=28VMware=29?= To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, torvalds@linux-foundation.org, kirill@shutemov.name Cc: Thomas Hellstrom Subject: [RFC PATCH 4/4] mm: mapping_dirty_helpers: Handle huge pmds correctly Date: Thu, 10 Oct 2019 15:40:58 +0200 Message-Id: <20191010134058.11949-5-thomas_os@shipmail.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191010134058.11949-1-thomas_os@shipmail.org> References: <20191010134058.11949-1-thomas_os@shipmail.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001477, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Thomas Hellstrom We always do dirty tracking on the PTE level. This means that any huge pmds we encounter should be read-only and not dirty: We can just skip those. Write-enabled huge pmds should not exist. They should have been split when made write-enabled. Warn and attempt to split them. Signed-off-by: Thomas Hellstrom --- mm/mapping_dirty_helpers.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mm/mapping_dirty_helpers.c b/mm/mapping_dirty_helpers.c index 799b9154b48f..f61bb9de1530 100644 --- a/mm/mapping_dirty_helpers.c +++ b/mm/mapping_dirty_helpers.c @@ -115,11 +115,18 @@ static int clean_record_pte(pte_t *pte, unsigned long addr, static int wp_clean_pmd_entry(pmd_t *pmd, unsigned long addr, unsigned long end, struct mm_walk *walk) { - /* Dirty-tracking should be handled on the pte level */ pmd_t pmdval = pmd_read_atomic(pmd); - if (pmd_trans_huge(pmdval) || pmd_devmap(pmdval)) - WARN_ON(pmd_write(pmdval) || pmd_dirty(pmdval)); + /* + * Dirty-tracking should be handled on the pte level, and write- + * enabled huge PMDS should never have been created. Warn on those. + * Read-only huge PMDS can't be dirty so we just skip them. + */ + if (pmd_trans_huge(pmdval) || pmd_devmap(pmdval)) { + if (WARN_ON(pmd_write(pmdval) || pmd_dirty(pmdval))) + return 0; + return PAGE_WALK_CONTINUE; + } return 0; }