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 BA7B4C67871 for ; Thu, 27 Oct 2022 07:08:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63B008E0003; Thu, 27 Oct 2022 03:08:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E8B78E0001; Thu, 27 Oct 2022 03:08:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B2898E0003; Thu, 27 Oct 2022 03:08:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3A2698E0001 for ; Thu, 27 Oct 2022 03:08:41 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1C76CA04EB for ; Thu, 27 Oct 2022 07:08:41 +0000 (UTC) X-FDA: 80065851642.05.A167D65 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf06.hostedemail.com (Postfix) with ESMTP id B7F3518001B for ; Thu, 27 Oct 2022 07:08:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=2PK2CcB6XE27IhF1KIVx3VDxBzlt6BtNKHFrbWiKaXU=; b=Q3vJ0Ym6DiUw65O0d6LOwaKcZs isOPaNOc1ZoZuICDKd0z9TdyXZ/tx+pscIx/xmw6UznSin07bfxqPDtD/V7LzdEzM0v/U8YlkkAEm PPlCwpACwIXUuDXo8JYYcGq8alNOYGZ0VHyi4HQATPDqaYbPmo9dEcKZCqW+gv56N4Zg0hcGB5sZb 08N9Iz9a2HV0yFlr64TKeouvrMZ0wu7ZfZ7Nd1fklGTSJ+qH8zrZX+HKh6X/tHvrelVzcM1PsAigL scYiEUrd4g5jNSXF9B5CWaae22d0JwPX1nqHBSyPlQVd6AOF80CiCjwMh62onLC8klYLLcp+64O11 mFVUejxw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1onx0C-006nOn-14; Thu, 27 Oct 2022 07:08:32 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 4BEB4300411; Thu, 27 Oct 2022 09:08:31 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 34D392012BEF9; Thu, 27 Oct 2022 09:08:31 +0200 (CEST) Date: Thu, 27 Oct 2022 09:08:31 +0200 From: Peter Zijlstra To: Jann Horn Cc: John Hubbard , x86@kernel.org, willy@infradead.org, torvalds@linux-foundation.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, aarcange@redhat.com, kirill.shutemov@linux.intel.com, jroedel@suse.de, ubizjak@gmail.com Subject: Re: [PATCH 01/13] mm: Update ptep_get_lockless()s comment Message-ID: References: <20221022111403.531902164@infradead.org> <20221022114424.515572025@infradead.org> <2c800ed1-d17a-def4-39e1-09281ee78d05@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666854520; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2PK2CcB6XE27IhF1KIVx3VDxBzlt6BtNKHFrbWiKaXU=; b=PzFiS9wUvJa8rS6pDMjPZBqrApSHW05JpLB6wKZiID3HzFGzVPT8ZocSwpSchvAWPzaflS O8zSJe7UoiIhy4pm7D7OeZdAZU7YLwdwKFfgc+FJM+klCmxV26g9ZV2V80r9gAxr8s0PAp eEgYBBrbWdJ+d5IIVrhgZJb4Dlf5Gms= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=Q3vJ0Ym6; spf=none (imf06.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666854520; a=rsa-sha256; cv=none; b=4Gv096pG070jyntNRh8ubwkN97svhvjlmCtFdKXrB1yU03dvLzRFkqb1lnQh8TZdyHKW2k 0DnasbNucI314ZyhThXSEJy0nA1ohEVg/grhXInTPmO5Vh9WNFyqfFP77CGzNF97M/MuFZ O/TJOAOhvXblZW4CwVrXIGZ7vW5hXtA= X-Rspamd-Queue-Id: B7F3518001B Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=Q3vJ0Ym6; spf=none (imf06.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam10 X-Stat-Signature: f65rtd6xxsaofcw8cws5d1ephr3tgme9 X-HE-Tag: 1666854519-348437 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 Wed, Oct 26, 2022 at 06:45:16PM +0200, Jann Horn wrote: > > #endif /* _LINUX_MM_H */ > > diff --git a/mm/memory.c b/mm/memory.c > > index f88c351aecd4..9bb63b3fbee1 100644 > > --- a/mm/memory.c > > +++ b/mm/memory.c > > @@ -1440,6 +1440,11 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, > > tlb_remove_tlb_entry(tlb, pte, addr); > > zap_install_uffd_wp_if_needed(vma, addr, pte, details, > > ptent); > > + > > + if (!force_flush && !tlb->fullmm && details && > > + details->zap_flags & ZAP_FLAG_FORCE_FLUSH) > > + force_flush = 1; > > + > > Hmm... I guess that might work, assuming that there is no other > codepath we might race with that first turns the present PTE into a > non-present PTE but keeps the flush queued for later. At least > codepaths that use the tlb_batched infrastructure are unproblematic... So I thought the general rule was that if you modify a PTE and have not unmapped things -- IOW, there's actual concurrency possible on the thing, then the TLB invalidate needs to happen under pte_lock, since that is what controls concurrency at the pte level. As it stands MADV_DONTNEED seems to blatatly violate that general rule. Then again; I could've missed something and the rules changed?