Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3194680rwb; Mon, 16 Jan 2023 05:07:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXslb9r3wUr4fzF9ia72/TRDyvCjLIDZoc+R6d9OpZKOptKha5Mfz298OJjUvNscmquwPwJy X-Received: by 2002:a17:907:3f95:b0:7c0:d609:6f9b with SMTP id hr21-20020a1709073f9500b007c0d6096f9bmr14924600ejc.27.1673874440540; Mon, 16 Jan 2023 05:07:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673874440; cv=none; d=google.com; s=arc-20160816; b=O8lmMyqFPqF8HVDKQGS7UDU3ubr6VGVVULYmmF5OvuAzo6mdM1ck9mAqBsR/cCG7oq AgusnLVpV9WADtUsDM5BAndtx72fEPD8yrhs1d0jhlQE2VIMM866l74ACnIK67zbvo2s 5DAIjKI7JyZ3TX+gCu/6gR7rL5j4xWmn1WuYzdf1Sqi+4T9O/heC6TeDVWO0XOudkKN0 pyvDf7/mfbY9/NDnPkLOAQryLg8j7MK/gJFaUFOb9F6HJMXfCw4LmGjUwb4t1O4AXlsU 7p3Oqk2Js7m7k/RfXsg8N4IVS2T4o8Zpo4wiZKLWn/w7Ia3gzWtbN2HpZSPwjnPMHP1Z w5/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=3SxhgAvgDMdZQpeBwjT3HHcfCZOqbwGa4aErLEE5tZo=; b=uOOq+9agbqeL0z8YKaCOsJ0Fj+1p7oHl+fD2V587uYIJ248yRzrGibe0xG+r5Yz9Uv G2ER7OPOc0Ej3tf737ylccjYjsOYtMlA3f5bDQx70BdHr6ig69Se+6F5ztcdRp6Y3Yp5 39bOpJI42RLU+0LvTtvZcvGosQAYQpkj06h7zf1d6itBf34TLfl4flEc6MpFQvgAcKyQ q+ixCqviPYoSOyjWJcQu3ME2X2XNAsKFrmKSE8DaYh/6eL/0/pN+X0bYnw3qb/Psyluf 9VudYAy9Q8xqd+pnxz0FEJa1a5kJ9L3uzcKuaC9QM1FJuYqfHa6s3Nh4bg/H2HRWiAGL aECw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=WwyqIv5u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wz8-20020a170906fe4800b007ae9f42f86esi7439533ejb.383.2023.01.16.05.07.07; Mon, 16 Jan 2023 05:07:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=WwyqIv5u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231344AbjAPM43 (ORCPT + 51 others); Mon, 16 Jan 2023 07:56:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231206AbjAPM4E (ORCPT ); Mon, 16 Jan 2023 07:56:04 -0500 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F6361E5D7 for ; Mon, 16 Jan 2023 04:54:49 -0800 (PST) Received: by mail-il1-x133.google.com with SMTP id w2so218398ilg.1 for ; Mon, 16 Jan 2023 04:54:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=3SxhgAvgDMdZQpeBwjT3HHcfCZOqbwGa4aErLEE5tZo=; b=WwyqIv5ugeBGMCRLeuLpLHV07NTeipvLkTInSKY42RrdU1vwWtTEUtYdXEw52BsKUK UWbwuyCoIkqFYwgNoVURc0Qd+yxukDctYsO4kMlxKDHjOhHUUDxij8rPJZdn7baGV7R8 IVwBQmT+J8xjrPnEg5xWbuKr7an/po/Xo4dLxEruoxwIofEZklyzkoBABsbLvFeyVXMY saELXXNxzqPU2fIV2Hqg3KsVwrn/54eK6/5MJCNxToqkQApDvz/lHFtoOs4Q/txSM+rL bSn40FZt6uIxSLwD06kXtY7RC8GwxwprFjIrn1reOzSKbr9dWMwZZpaz+jeAOjNsEU9g WxVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3SxhgAvgDMdZQpeBwjT3HHcfCZOqbwGa4aErLEE5tZo=; b=tFqXxBPjKa4E79lBFKCWOALVlJrX9cehnw5sYLQgRnVakOe2DE39t/2PRz++2hns8q cHwvP81MJ6q/V3v563lxGqbX9MeIOC9ySCBTV7Flwutppu+eM2n6usEDuqteaalHEXBT zRJR3KUlkf7u+osGI6i51Bk3dDjGth6MlyCiicyKR+zMbF5hNHr+8oUyqY0gJZfJH5Rn Q38AcuA+Nyfyp0L5aIqC6h71yDymTZmubmahY71vz8UEQyC+wvk9P5fPnMnJ0mBzGJHL GwRHR01O/2p2+rpn9TqUbMhzDH7U1jrH/EXv4XR6/20MCXX5zMhsCUskk5Yl+E5voupV CVCQ== X-Gm-Message-State: AFqh2kotd68YQO/zdKLo+G4Q8v/YhOolXEy2x7yuxqdU7FiqPUWMSfZ4 wKaBHujD9TsIGX7fIfYaa/OuRVcy281J40rVM36XbQ== X-Received: by 2002:a92:c04e:0:b0:30f:12c9:f765 with SMTP id o14-20020a92c04e000000b0030f12c9f765mr116249ilf.187.1673873688380; Mon, 16 Jan 2023 04:54:48 -0800 (PST) MIME-Version: 1.0 References: <20230111133351.807024-1-jannh@google.com> <20230112085649.gvriasb2t5xwmxkm@box.shutemov.name> <20230115190654.mehtlyz2rxtg34sl@box.shutemov.name> <20230116123403.fiyv22esqgh7bzp3@box.shutemov.name> In-Reply-To: <20230116123403.fiyv22esqgh7bzp3@box.shutemov.name> From: Jann Horn Date: Mon, 16 Jan 2023 13:54:12 +0100 Message-ID: Subject: Re: [PATCH] mm/khugepaged: Fix ->anon_vma race To: "Kirill A. Shutemov" Cc: Andrew Morton , linux-mm@kvack.org, "Kirill A. Shutemov" , "Zach O'Keefe" , linux-kernel@vger.kernel.org, David Hildenbrand , Yang Shi , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +cc mmu-gather maintainers On Mon, Jan 16, 2023 at 1:34 PM Kirill A. Shutemov wrote: > On Mon, Jan 16, 2023 at 01:06:59PM +0100, Jann Horn wrote: > > On Sun, Jan 15, 2023 at 8:07 PM Kirill A. Shutemov wrote: > > > BTW, I've noticied that you recently added tlb_remove_table_sync_one(). > > > I'm not sure why it is needed. Why IPI in pmdp_collapse_flush() in not > > > good enough to serialize against GUP fast? > > > > If that sent an IPI, it would be good enough; but > > pmdp_collapse_flush() is not guaranteed to send an IPI. > > It does a TLB flush, but on some architectures (including arm64 and > > also virtualized x86), a remote TLB flush can be done without an IPI. > > For example, arm64 has some fancy hardware support for remote TLB > > invalidation without IPIs ("broadcast TLB invalidation"), and > > virtualized x86 has (depending on the hypervisor) things like TLB > > shootdown hypercalls (under Hyper-V, see hyperv_flush_tlb_multi) or > > TLB shootdown signalling for preempted CPUs through shared memory > > (under KVM, see kvm_flush_tlb_multi). > > I think such architectures must provide proper pmdp_collapse_flush() > with the required serialization. FWIW, the IPI that I added is not unconditional; tlb_remove_table_sync_one() is a no-op depending on CONFIG_MMU_GATHER_RCU_TABLE_FREE, which an architecture can use to signal that it uses "Semi RCU freeing of the page directories". The kernel has arch-independent support for these semantics in the normal TLB flushing code. But yeah, I guess you could move the tlb_remove_table_sync_one() calls into pmdp_collapse_flush() (including the generic version)? I'm CC-ing the mmu-gather maintainers in case they have an opinion. Anyway, I'm not going to do that refactor; feel free to do that if you want. > Power and S390 already do that. What's the call graph from pmdp_collapse_flush() to IPI on powerpc and s390?