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 30FD4C433F5 for ; Fri, 4 Feb 2022 19:59:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 655BF6B0085; Fri, 4 Feb 2022 14:59:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C2FB6B0089; Fri, 4 Feb 2022 14:59:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0C306B007B; Fri, 4 Feb 2022 14:59:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id A4F2C6B007E for ; Fri, 4 Feb 2022 14:59:05 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 662A51827E8E1 for ; Fri, 4 Feb 2022 19:59:05 +0000 (UTC) X-FDA: 79106161050.30.4C21251 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id 1D459160002 for ; Fri, 4 Feb 2022 19:59:04 +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=NOZFCIAHs14S6ShgmEZTYVvlwYIX+9q1FzDwIHERWMU=; b=oSzUzWyoXWPtOg5IDBWJS2HMsY LIoT7FbLieUlfRoqAfRmp+S5USjt7whN6+vx0tWMS+rT4fg6TIwnpgzKT+bNASFMiG1xLjEbLMKyv jAIsN+Pk9H7Qm4nszlO4EIRKLGmVXTyTh7PJtSSHwOm4PIZqIyIR7N5jR+KWmC52n2bxR3Ya3oAYp n8SAiuLo9SRHmXntPDmrDZgennQCO60kdOCcqio2Bf+PkxbZLSjtFLTzM23uCWQ0IbLzNYAWRQd0V ElOzXete8NXsvVAxnbv+jsL9HJDTRxvcbjl1ijsgW7a1jj7pKS/B48lde/TSUGiGT3O/jXIzQVp4H Szz3ek6Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG4jT-007Ll3-Nl; 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 Subject: [PATCH 01/75] mm/gup: Increment the page refcount before the pincount Date: Fri, 4 Feb 2022 19:57:38 +0000 Message-Id: <20220204195852.1751729-2-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 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=oSzUzWyo; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspam-User: nil X-Rspamd-Queue-Id: 1D459160002 X-Stat-Signature: 8zsxd95ey478ngcxsne63xi518otttmg X-Rspamd-Server: rspam12 X-HE-Tag: 1644004744-154817 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: We should always increase the refcount before doing anything else to the page so that other page users see the elevated refcount first. Signed-off-by: Matthew Wilcox (Oracle) --- mm/gup.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index a9d4d724aef7..08020987dfc0 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -220,18 +220,18 @@ bool __must_check try_grab_page(struct page *page, = unsigned int flags) if (WARN_ON_ONCE(page_ref_count(page) <=3D 0)) return false; =20 - if (hpage_pincount_available(page)) - hpage_pincount_add(page, 1); - else - refs =3D GUP_PIN_COUNTING_BIAS; - /* * 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. */ - page_ref_add(page, refs); + if (hpage_pincount_available(page)) { + page_ref_add(page, 1); + hpage_pincount_add(page, 1); + } else { + page_ref_add(page, GUP_PIN_COUNTING_BIAS); + } =20 mod_node_page_state(page_pgdat(page), NR_FOLL_PIN_ACQUIRED, 1); } --=20 2.34.1