From patchwork Mon Nov 30 11:27:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 11940245 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B0C9C64E7B for ; Mon, 30 Nov 2020 11:38:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BD9D42087C for ; Mon, 30 Nov 2020 11:38:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="su+36IVy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD9D42087C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D29678D0003; Mon, 30 Nov 2020 06:38:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CD9898D0001; Mon, 30 Nov 2020 06:38:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF1CD8D0003; Mon, 30 Nov 2020 06:38:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id A93218D0001 for ; Mon, 30 Nov 2020 06:38:24 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6F85D3634 for ; Mon, 30 Nov 2020 11:38:24 +0000 (UTC) X-FDA: 77540886528.06.loaf13_3515224273a1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 49B4310041A00 for ; Mon, 30 Nov 2020 11:38:24 +0000 (UTC) X-HE-Tag: loaf13_3515224273a1 X-Filterd-Recvd-Size: 3079 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Mon, 30 Nov 2020 11:38:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=UiVGVeFLRq7zVPo40bMLNVgAJoLSCFMPhHigNy3P9ck=; b=su+36IVymoYyHjztNNWkljSkgM +0Crf3dx2ZnLdzrBXvO0ylXLyyl72BD55GrGQA1gkGoDBQy3e4fswH/PgmwajJNNXKEsgGM8MwCRe NuejYRToqRn3+BQINeTsw44xll9bOLVTWw8iQqEXF5aKJ3MOzZjXgSrnYIWBapz4ySRJ+/zgofBJL xVXbGyWYrRs7mTgev5RRdc9ROcTavZtbfJ56v7j3gIehKdJNjwaLeaTPoiT72+7ORYvYiVkK5OBYb EjCOGasOe2zX5Kpcn4vb2ZTQF6ceB9GIusmHZOoUNpebQQtLH2sImbfg7LwSA6cTAn6V/lfi1AIy4 M9n1SfQQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kjhVc-0007Qr-5Z; Mon, 30 Nov 2020 11:38:20 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 3508530769C; Mon, 30 Nov 2020 12:38:18 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id E46F42B84F9C3; Mon, 30 Nov 2020 12:38:17 +0100 (CET) Message-ID: <20201130113603.145310991@infradead.org> User-Agent: quilt/0.66 Date: Mon, 30 Nov 2020 12:27:11 +0100 From: Peter Zijlstra To: x86@kernel.org, willy@infradead.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, aarcange@redhat.com, kirill.shutemov@linux.intel.com, jroedel@suse.de, peterz@infradead.org Subject: [RFC][PATCH 6/9] mm/gup: Fix the lockless walkers References: <20201130112705.900705277@infradead.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: On architectures where the PTE/PMD is larger than the native word size (i386-PAE for example), READ_ONCE() can do the wrong thing. Use pmdp_get_lockless() just like we use ptep_get_lockless(). Signed-off-by: Peter Zijlstra (Intel) --- kernel/events/core.c | 2 +- mm/gup.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7041,7 +7041,7 @@ static u64 perf_get_pgtable_size(struct return pud_leaf_size(pud); pmdp = pmd_offset_lockless(pudp, pud, addr); - pmd = READ_ONCE(*pmdp); + pmd = pmdp_get_lockless(pmdp); if (!pmd_present(pmd)) return 0; --- a/mm/gup.c +++ b/mm/gup.c @@ -2467,7 +2467,7 @@ static int gup_pmd_range(pud_t *pudp, pu pmdp = pmd_offset_lockless(pudp, pud, addr); do { - pmd_t pmd = READ_ONCE(*pmdp); + pmd_t pmd = pmdp_get_lockless(pmdp); next = pmd_addr_end(addr, end); if (!pmd_present(pmd))