From patchwork Fri Feb 4 19:57:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12735585 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 ED3AEC433EF for ; Fri, 4 Feb 2022 20:21:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D05128D0008; Fri, 4 Feb 2022 15:21:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B9E368D0005; Fri, 4 Feb 2022 15:21:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A18298D0007; Fri, 4 Feb 2022 15:21:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id 91CD38D0005 for ; Fri, 4 Feb 2022 15:21:37 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CE04195CB1 for ; Fri, 4 Feb 2022 20:21:36 +0000 (UTC) X-FDA: 79106217792.23.D6A5ED2 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf03.hostedemail.com (Postfix) with ESMTP id 0C7E220003 for ; Fri, 4 Feb 2022 20:21:35 +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=B2OutkWqU99op9mi/t36gPZ4A2y3PkyT8m7uUSFjSLM=; b=fvbCRW8wvKcgxDc7/d2nOz3wgX 5EEViXGpdXarWthRN4a94d0pghpcjAKfz1WgOZqg/kFXUwq6D2rRUTsziDquIhIUU3BHOENV3F71+ IMU5sT/VG2xqonF0VXBvElWHJzy+pRmAX5zs1z4R2yZZ9ekjxzKGerG/O6I3ypHOoJNZHDpbuiBJF nA+i3BFBcDsWUObDlj89jv2weGH/VvhExSGstVkqoOa9F+JruOX8dOgZuA5BQEg6Th6xUgsY+8jGr Olp1DpWXPYL9z2KvbAS1Hr79yiOjRVMAsmjzpU6MaIb/iSM30IcrPpR3NnAE8Pf/Nc9JuZxYwMNdR g/fcwTmQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG4jT-007Ll7-Sj; Fri, 04 Feb 2022 19:58:59 +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 03/75] mm/gup: Remove for_each_compound_head() Date: Fri, 4 Feb 2022 19:57:40 +0000 Message-Id: <20220204195852.1751729-4-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: 0C7E220003 X-Stat-Signature: 9thk7r9p9uuhedjxfnj3hyhp3k787mfz Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=fvbCRW8w; 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: 1644006095-278203 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 macro doesn't simplify the users; it's easier to just call compound_next() inside a standard loop. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig Reviewed-by: John Hubbard Reviewed-by: Jason Gunthorpe Reviewed-by: William Kucharski --- mm/gup.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index dc00e46fae5a..facadcaedea3 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -278,9 +278,6 @@ static inline void compound_next(unsigned long i, unsigned long npages, struct page *page; unsigned int nr; - if (i >= npages) - return; - page = compound_head(list[i]); for (nr = i + 1; nr < npages; nr++) { if (compound_head(list[nr]) != page) @@ -291,12 +288,6 @@ static inline void compound_next(unsigned long i, unsigned long npages, *ntails = nr - i; } -#define for_each_compound_head(__i, __list, __npages, __head, __ntails) \ - for (__i = 0, \ - compound_next(__i, __npages, __list, &(__head), &(__ntails)); \ - __i < __npages; __i += __ntails, \ - compound_next(__i, __npages, __list, &(__head), &(__ntails))) - /** * unpin_user_pages_dirty_lock() - release and optionally dirty gup-pinned pages * @pages: array of pages to be maybe marked dirty, and definitely released. @@ -331,7 +322,8 @@ void unpin_user_pages_dirty_lock(struct page **pages, unsigned long npages, return; } - for_each_compound_head(index, pages, npages, head, ntails) { + for (index = 0; index < npages; index += ntails) { + compound_next(index, npages, pages, &head, &ntails); /* * Checking PageDirty at this point may race with * clear_page_dirty_for_io(), but that's OK. Two key @@ -419,8 +411,10 @@ void unpin_user_pages(struct page **pages, unsigned long npages) if (WARN_ON(IS_ERR_VALUE(npages))) return; - for_each_compound_head(index, pages, npages, head, ntails) + for (index = 0; index < npages; index += ntails) { + compound_next(index, npages, pages, &head, &ntails); put_compound_head(head, ntails, FOLL_PIN); + } } EXPORT_SYMBOL(unpin_user_pages);