From patchwork Mon Nov 30 11:27:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 11940257 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 2A6A5C64E7B for ; Mon, 30 Nov 2020 11:38:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8732A206C1 for ; Mon, 30 Nov 2020 11:38:33 +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="2/ThSzwG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8732A206C1 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 238A78D0001; Mon, 30 Nov 2020 06:38:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E1E698D0005; Mon, 30 Nov 2020 06:38:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B573F8D0008; Mon, 30 Nov 2020 06:38:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id 8DA958D0005 for ; Mon, 30 Nov 2020 06:38:25 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 50DE51EE6 for ; Mon, 30 Nov 2020 11:38:25 +0000 (UTC) X-FDA: 77540886570.12.train84_5f14ea4273a1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 215AD1801F0F0 for ; Mon, 30 Nov 2020 11:38:25 +0000 (UTC) X-HE-Tag: train84_5f14ea4273a1 X-Filterd-Recvd-Size: 3875 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Mon, 30 Nov 2020 11:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=p4owENHTSGpOxSLxjnv01cC/b4aSY2KNSrKXKhQFpp0=; b=2/ThSzwGx8iKGWVBXcvf+IhJ95 tu7jvyTICS7JwwwSKX20c35Lpo6UlFWfAqTGCKkGGcO7izqEDpnTa3kioX8M1La2C2NwzGmtXHVnA bDptqOsODjFjZKrt4I/NY0vtaY8OZwAffyjLnPMKywcT5wJCwM5YhBkBgpx3tO8DHoAIEUTeE5xnx Jb9WaHWZYpt00qnD7JQMbSOPypOIXGgUd3NivAB4VHk3LuCH1venb1emG+bYDo2tPvmyuYjYrrVsy m5HLED4lbjB+Uq+TUbbkVr5jCVPTPxtStatP2fMSkYgDVIxzshiZSUq+vCHbGeIToei25DPYkYccD qoAKEj2w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kjhVc-0006CV-Gb; 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 E3C19302753; Mon, 30 Nov 2020 12:38:17 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id D10902B84F9AE; Mon, 30 Nov 2020 12:38:17 +0100 (CET) Message-ID: <20201130113602.841001656@infradead.org> User-Agent: quilt/0.66 Date: Mon, 30 Nov 2020 12:27:06 +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 1/9] mm: Update ptep_get_lockless()s comment 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: Improve the comment and add a lockdep assertion because nobody reads comments. Suggested-by: Matthew Wilcox Signed-off-by: Peter Zijlstra (Intel) --- include/linux/pgtable.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -260,15 +260,12 @@ static inline pte_t ptep_get(pte_t *ptep #ifdef CONFIG_GUP_GET_PTE_LOW_HIGH /* - * WARNING: only to be used in the get_user_pages_fast() implementation. - * - * With get_user_pages_fast(), we walk down the pagetables without taking any - * locks. For this we would like to load the pointers atomically, but sometimes - * that is not possible (e.g. without expensive cmpxchg8b on x86_32 PAE). What - * we do have is the guarantee that a PTE will only either go from not present - * to present, or present to not present or both -- it will not switch to a - * completely different present page without a TLB flush in between; something - * that we are blocking by holding interrupts off. + * For walking the pagetables without holding any locks. Some architectures + * (eg x86-32 PAE) cannot load the entries atomically without using expensive + * instructions. We are guaranteed that a PTE will only either go from not + * present to present, or present to not present -- it will not switch to a + * completely different present page without a TLB flush inbetween; which we + * are blocking by holding interrupts off. * * Setting ptes from not present to present goes: * @@ -294,6 +291,8 @@ static inline pte_t ptep_get_lockless(pt { pte_t pte; + lockdep_assert_irqs_disabled(); + do { pte.pte_low = ptep->pte_low; smp_rmb();