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 494C0C433EF for ; Fri, 4 Feb 2022 20:00:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CD8B8D0018; Fri, 4 Feb 2022 14:59:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 18C396B00A2; Fri, 4 Feb 2022 14:59:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD4C96B0095; Fri, 4 Feb 2022 14:59:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0247.hostedemail.com [216.40.44.247]) by kanga.kvack.org (Postfix) with ESMTP id 755056B00A2 for ; Fri, 4 Feb 2022 14:59:11 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 371AF1816C8D5 for ; Fri, 4 Feb 2022 19:59:11 +0000 (UTC) X-FDA: 79106161302.22.F0EE95E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id D84B140002 for ; Fri, 4 Feb 2022 19:59:10 +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=PfQOTVgeWGT3scFV19Cd1ZaUkxymD+QBS63EkVoXSxc=; b=RZJM0dLLF/gofYIbSl2YdKP9eL 1FE4YMufpbI/R4pqNQslFtv2i0QMRYfiyB7Br9Adb8iamSp1IPvVktun+X2Jv44rzt3pmGDbOHHzq 2TeUyH/6/g40XJ0WMDNf4jNGSmJ9xbbsSLfc9z67VdK/hN/G2E10w1+2re2TSUy60iR6LTPBnQijK PhDquH+eVokp6L4mfiCLWbXCwWzNd2sm/sF1lSVTUfWpI/0ZAK/fjlOFUvqtJleBLxu0JB2mg+8N7 tr1J/9hex36g7BA2P4U5l7gEdbjo8msqS893Z+RpDJ/MMpZ8j0j4R3qs3EpjCpwE8mbkUsvQJV7e1 NCT1i5Jw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG4jU-007LlL-EQ; 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 Subject: [PATCH 10/75] mm/gup: Remove hpage_pincount_add() Date: Fri, 4 Feb 2022 19:57:47 +0000 Message-Id: <20220204195852.1751729-11-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-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: D84B140002 X-Stat-Signature: cxzqmphrk6gaw9tbqaqqejx6ibsxzh68 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=RZJM0dLL; dmarc=none; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: nil X-HE-Tag: 1644004750-207660 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: It's clearer to call atomic_add() in the callers; the assertions clearly can't fire there because they're part of the condition for calling atomic_add(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/gup.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 923a0d44203c..60168a09d52a 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -29,14 +29,6 @@ struct follow_page_context { unsigned int page_mask; }; =20 -static void hpage_pincount_add(struct page *page, int refs) -{ - VM_BUG_ON_PAGE(!hpage_pincount_available(page), page); - VM_BUG_ON_PAGE(page !=3D compound_head(page), page); - - atomic_add(refs, compound_pincount_ptr(page)); -} - static void hpage_pincount_sub(struct page *page, int refs) { VM_BUG_ON_PAGE(!hpage_pincount_available(page), page); @@ -151,17 +143,17 @@ __maybe_unused struct page *try_grab_compound_head(= struct page *page, return NULL; =20 /* - * When pinning a compound page of order > 1 (which is what - * hpage_pincount_available() checks for), use an exact count to - * track it, via hpage_pincount_add/_sub(). + * When pinning a compound page of order > 1 (which is + * what hpage_pincount_available() checks for), use an + * exact count to track it. * - * However, be sure to *also* increment the normal page refcount - * field at least once, so that the page really is pinned. - * That's why the refcount from the earlier + * However, be sure to *also* increment the normal page + * refcount field at least once, so that the page really + * is pinned. That's why the refcount from the earlier * try_get_compound_head() is left intact. */ if (hpage_pincount_available(page)) - hpage_pincount_add(page, refs); + atomic_add(refs, compound_pincount_ptr(page)); else page_ref_add(page, refs * (GUP_PIN_COUNTING_BIAS - 1)); =20 @@ -216,22 +208,19 @@ bool __must_check try_grab_page(struct page *page, = unsigned int flags) if (flags & FOLL_GET) return try_get_page(page); else if (flags & FOLL_PIN) { - int refs =3D 1; - page =3D compound_head(page); =20 if (WARN_ON_ONCE(page_ref_count(page) <=3D 0)) return false; =20 /* - * Similar to try_grab_compound_head(): even if using the - * hpage_pincount_add/_sub() routines, be sure to - * *also* increment the normal page refcount field at least - * once, so that the page really is pinned. + * Similar to try_grab_compound_head(): be sure to *also* + * increment the normal page refcount field at least once, + * so that the page really is pinned. */ if (hpage_pincount_available(page)) { page_ref_add(page, 1); - hpage_pincount_add(page, 1); + atomic_add(1, compound_pincount_ptr(page)); } else { page_ref_add(page, GUP_PIN_COUNTING_BIAS); } --=20 2.34.1