Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3191045rwb; Mon, 16 Jan 2023 05:04:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXs9uKG66RjVK28HHPWDNfcrcfDxC2y2AQZfYqZ+Pu5w+Qfbs57L1XXVq6ks0uJBGB6k0YF0 X-Received: by 2002:a17:906:6c93:b0:86c:f7ac:71ff with SMTP id s19-20020a1709066c9300b0086cf7ac71ffmr9000372ejr.10.1673874299566; Mon, 16 Jan 2023 05:04:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673874299; cv=none; d=google.com; s=arc-20160816; b=TrC906ZcZlhuKIhAHn7x2KTcF4qLUyvEuVrPBigtmQbBSygiNqptc2Yg81iupGXnfy I1UCFswslUnuoIuBWphirgk/aUnjgh5CzHUGsGH1kQzvtoDJkTcv8KRcl9+QBzLRL0J2 oLJCcbdMYXNiBKJfCedzfOwBmpvV7IL2U6ryfWDXTUjc8d7cKewS7ATuQVOlol4cL6/c 1xO7cTm2ihMZXF37NnBRS8+ACO64HLbVTVvoBnOa02L4PE5W14/j97CVd3QE354vcVxz jbCELouGlyzvArzR63+xWBLOKQ1exhP0Q9PpAS5kL8YXxLqI1ipW4yRvKP9MgIZ3yRH1 FPZw== 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=btqxdj2qYR3AcspG5TzORiD8Ae2hoP6388ovBCbCzvQ=; b=vnbTWS+QqEZOr6xmnf8bmyZdWAzQ0jP/pv3MODGprAc7jXg5lht65F4GrmWRccWvgQ Nu8a78norW8nuWyy/nJT0/lcgiLKG7BPmWR5G/uBCQrwPj0+lHQlrpPUez48vlxWbRSo juqkcjYxvFGc3LcqZFPMOH+O5ALkqZzyUO52dlTI3QLAuZ8+hYcLqsgyvcvy9Gcjhu3f ygzVkNler5xrDBsl8HB8rf2ylTx0xMa8B6/i7HnHgyFp7BnaWFnE/X388lVWoLoGd5xp U7TfU3hfNQH249mJ6+dJp5Hyr61sG4RcKLLm+1MtU454C427hKBkuqtNswSDyvs/pwuB k9og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=kfUFMt6b; 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 bf23-20020a0564021a5700b0049e283e04d9si648252edb.115.2023.01.16.05.04.46; Mon, 16 Jan 2023 05:04:59 -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=kfUFMt6b; 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 S229883AbjAPMHk (ORCPT + 51 others); Mon, 16 Jan 2023 07:07:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbjAPMHh (ORCPT ); Mon, 16 Jan 2023 07:07:37 -0500 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDA90196BF for ; Mon, 16 Jan 2023 04:07:36 -0800 (PST) Received: by mail-io1-xd2e.google.com with SMTP id h184so4053102iof.9 for ; Mon, 16 Jan 2023 04:07:36 -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=btqxdj2qYR3AcspG5TzORiD8Ae2hoP6388ovBCbCzvQ=; b=kfUFMt6bSOO3PRs7Bj1FxJ+7CsqSX1DIwrcuOKSvZSHb0T4BlZtfZdlJTFUcoCzZu7 8fwP0zfvg1wi9LDSPb2Ib3hs4Bc1ki1SoPRJ2h/NLXS6SkmnDNoYa31GEYWLtJ0CNzRb E+FY/WsEMqg5TQC0FLvkPznJSlyqSjO4BX7BjAT61KZU9WBzGU68JTmjQ5IZHSJWj/g8 LqyHJZlapgaANi4fUB1iNUjryz7aAF6VzStnPpR+aaBhsblQtxQxrWNQQAhRWUo1Mii2 I80K7NQ5ESMOlMjU8V1FQIgILOo3FZigaIBeVStkNj3pc2DC9uYvklay/x/N6yUvkb5/ K7TA== 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=btqxdj2qYR3AcspG5TzORiD8Ae2hoP6388ovBCbCzvQ=; b=XgVxHYXdjnMWkDwBlHTAeP7+r2DheBUFoybvyBOPvT2eN8iMEWAYaQ9KcIs2JiTPCj brVytkF1E0xLS/L0icS7/lVeIzV7sHN+dZtrF6HD5sJLudqsRl+3VK2rMPtTmUUhQawt xEVunIdFO//lRwjGnuYCSbVGD4tMUYcSefQ/d1kdC0Nool0oUD/WM2MlK+DXv+11zSX/ LvH3CzYhea9RJELbq5jRCAh02Kk58WBzOMxisVtNjhnTMNmHgKMPVQ6wRiLYmbK/6iGT yLWlq6Zl73l+5u6uzxNJM75WBQrZ9BiL50RR88DgspevaVZ/s1y9aIDPPXnCFtPFxF2b SsgA== X-Gm-Message-State: AFqh2kpHno10tz8IjYXeEMHARqh/6fmr6d7z9wzu6CuX6fU6JF2W9M9q XgYhS87YJl0J6Ip7OC8zLgUyhj9OsR3OQwyOMfMjNw== X-Received: by 2002:a05:6638:60c:b0:38c:886a:219a with SMTP id g12-20020a056638060c00b0038c886a219amr10328002jar.133.1673870855967; Mon, 16 Jan 2023 04:07:35 -0800 (PST) MIME-Version: 1.0 References: <20230111133351.807024-1-jannh@google.com> <20230112085649.gvriasb2t5xwmxkm@box.shutemov.name> <20230115190654.mehtlyz2rxtg34sl@box.shutemov.name> In-Reply-To: <20230115190654.mehtlyz2rxtg34sl@box.shutemov.name> From: Jann Horn Date: Mon, 16 Jan 2023 13:06:59 +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 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 On Sun, Jan 15, 2023 at 8:07 PM Kirill A. Shutemov wrote: > On Fri, Jan 13, 2023 at 08:28:59PM +0100, Jann Horn wrote: > > No, that lockdep assert has to be there. Page table traversal is > > allowed under any one of the mmap lock, the anon_vma lock (if the VMA > > is associated with an anon_vma), and the mapping lock (if the VMA is > > associated with a mapping); and so to be able to remove page tables, > > we must hold all three of them. > > Okay, that's fair. I agree with the patch now. Maybe adjust the commit > message a bit? Just to make sure we're on the same page: Are you suggesting that I add this text? "Page table traversal is allowed under any one of the mmap lock, the anon_vma lock (if the VMA is associated with an anon_vma), and the mapping lock (if the VMA is associated with a mapping); and so to be able to remove page tables, we must hold all three of them." Or something else? > Anyway: > > Acked-by: Kirill A. Shutemov Thanks! > 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).