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 EBAEFC433F5 for ; Fri, 4 Feb 2022 20:21:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C64136B0078; Fri, 4 Feb 2022 15:21:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BECA86B007B; Fri, 4 Feb 2022 15:21:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB33B6B007D; Fri, 4 Feb 2022 15:21:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0033.hostedemail.com [216.40.44.33]) by kanga.kvack.org (Postfix) with ESMTP id 9B06A6B0078 for ; Fri, 4 Feb 2022 15:21:33 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5554B182056EC for ; Fri, 4 Feb 2022 20:21:33 +0000 (UTC) X-FDA: 79106217666.04.0260E9A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf03.hostedemail.com (Postfix) with ESMTP id CCE4920009 for ; Fri, 4 Feb 2022 20:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=wHs6MVU8ScHq8HwASxu+WtvgZudUXxYv4AfDo2/UixE=; b=YYjyRdLE6KTkgmsiX/qoVe9qTG u5U00Pho6myWayUPcHV7iGMOTx+0zGnd2PztBPNTJO002X2dPO67twQ1I3oGOENv7N1jcIQR25ddR Wpmn9rX0YiCX8W15/5nmht+De3x4lIAZn1MmiW/MFLqgRqhU9BV/3jEuF0xOc5HAzqt0R7NGvitaI BHERmMeFnO7ZfNaGxlP94Bb+EesY54O65yvtX1uMwFNokRAa8MNWAbYcQG2PFzB/uG9sLYzwMZvna WNskPXsOll845+45h1DeXbJGSypF+4tWbbVFNIh2sV2oXbGN2o6Z7ktAODiZB0chZvfwkqIVZrTv/ /WjxTMkw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG4jU-007LlH-8J; Fri, 04 Feb 2022 19:59:00 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, Christoph Hellwig , John Hubbard , Jason Gunthorpe , William Kucharski Subject: [PATCH 08/75] mm/gup: Remove an assumption of a contiguous memmap Date: Fri, 4 Feb 2022 19:57:45 +0000 Message-Id: <20220204195852.1751729-9-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220204195852.1751729-1-willy@infradead.org> References: <20220204195852.1751729-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: nil X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: CCE4920009 X-Stat-Signature: hbxcaggjbztmdsymq6ew4qoqjpoobrxr Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YYjyRdLE; dmarc=none; spf=none (imf03.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1644006092-392107 Content-Transfer-Encoding: quoted-printable 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: This assumption needs the inverse of nth_page(), which is temporarily named page_nth() until it's renamed later in this series. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig Reviewed-by: John Hubbard Reviewed-by: Jason Gunthorpe Reviewed-by: William Kucharski --- include/linux/mm.h | 2 ++ mm/gup.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 213cc569b192..e679a7d66200 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -216,8 +216,10 @@ int overcommit_policy_handler(struct ctl_table *, in= t, void *, size_t *, =20 #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n)) +#define page_nth(head, tail) (page_to_pfn(tail) - page_to_pfn(head)) #else #define nth_page(page,n) ((page) + (n)) +#define page_nth(head, tail) ((tail) - (head)) #endif =20 /* to align the pointer to the (next) page boundary */ diff --git a/mm/gup.c b/mm/gup.c index 29a8021f10a2..fa75b71820a2 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -263,8 +263,8 @@ static inline struct page *compound_range_next(struct= page *start, next =3D nth_page(start, i); page =3D compound_head(next); if (PageHead(page)) - nr =3D min_t(unsigned int, - page + compound_nr(page) - next, npages - i); + nr =3D min_t(unsigned int, npages - i, + compound_nr(page) - page_nth(page, next)); =20 *ntails =3D nr; return page; --=20 2.34.1