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 99A67C46467 for ; Mon, 16 Jan 2023 12:07:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 125786B0073; Mon, 16 Jan 2023 07:07:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D6146B0074; Mon, 16 Jan 2023 07:07:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE0CA6B0075; Mon, 16 Jan 2023 07:07:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DE5756B0073 for ; Mon, 16 Jan 2023 07:07:39 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A844EC06FB for ; Mon, 16 Jan 2023 12:07:39 +0000 (UTC) X-FDA: 80360537838.28.F77928C Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) by imf03.hostedemail.com (Postfix) with ESMTP id 241BB2000D for ; Mon, 16 Jan 2023 12:07:36 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kfUFMt6b; spf=pass (imf03.hostedemail.com: domain of jannh@google.com designates 209.85.166.53 as permitted sender) smtp.mailfrom=jannh@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673870857; a=rsa-sha256; cv=none; b=ecbGHErgzH87vokGlTKBcTF16mcZKBJgrDIAAcMnbsAaNXsll807KJ92y5P3ynVD+yS2od xVGEU1/AXJkaWyPuru+nI+SIvmrKxyZJfzkchlErybvxSxdPnaULFo79Rq/zMpE0M2qHPX U3gnIg4okDg7jAz82/bzm5br4wgIDVg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kfUFMt6b; spf=pass (imf03.hostedemail.com: domain of jannh@google.com designates 209.85.166.53 as permitted sender) smtp.mailfrom=jannh@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673870857; 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=btqxdj2qYR3AcspG5TzORiD8Ae2hoP6388ovBCbCzvQ=; b=HcQJdBwnWmeOXMnovRB1aFOmZlcmh08vrDddN/f4FYXSgkIH/0b7q5a24u1xJXbvjp/VIg ATY4o2Ge9xQpMS4wumAqiVFrqwWs3Rhsdve/g2YOB4A+rN2l32ecoHi3iE5ovjRlbcMO9b mCzg9U/0d2P+R78k1X+aTUU8ANAwIVs= Received: by mail-io1-f53.google.com with SMTP id s26so5646771ioa.11 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=aV0WqMZtUBLmbtcPIH06US4gK9SGZPhb9mBirpSxiIMSIAYyFmwm0nc4NBu4gLiKa6 krtQk6cyroU9Xx1VNmT7unrR/9iGCcW4qytBM5GXwGH+oOGBuPt4U1c52xOEtpKZagQb GdWRYmoH3CH3QPPOgfVIEiuLhv1Z46UTDXwfOS0c2oWKfTc3f4LZ0AWpZTVCP8l7ojF9 O6s5c56zekZHkq9reMJb7K/1AOltbFHlsiB2SJ9Jd5nDhvT9HdO6N8dZvnjx9DJwZAhf Hlr0Mp4wj33A+X1g04SzcbnK+cGWBI5u8q0A3tbWD30tev43ZHyaw1aEy9+yhtjZwJss dNBA== X-Gm-Message-State: AFqh2koWjvtLO3/ISKPIhqic1NAa8u/01ZLBi9rO5QXdYfZRtdmacyq+ vSAntN6blSehrLZiRD0q6EZXwtTan4BXFoIOMEnm9w== X-Google-Smtp-Source: AMrXdXtK8RA6kn9nd4h7X9buHkAUghEIkCs/DwCg551iJI3FGcpgeyjr5JVjeWDQXg3yMkN7hKb0zUp/NQjNqDJGwvA= 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-Rspam-User: X-Rspamd-Queue-Id: 241BB2000D X-Rspamd-Server: rspam01 X-Stat-Signature: cyqwbuufnuibij5xmajcqm8haupjh9m9 X-HE-Tag: 1673870856-971193 X-HE-Meta: U2FsdGVkX1+9q85MnU+IeaVQFasVQqRdC8kIgBScH0KWflFA+2mf713z0IhlsXvC4ujesmYfUgDHlGRl9VltFpOw+b2gR/bx5b/S/02XxnILItt4NR+G0lqgY5H3ZOYf4w9htJLqG5+wduq5jB4JqVg6u0gDw7Igj5fgfB2BZvWY0JnpTS1nDK2Fbf/M5wVhhNlpm7DWeMnhAOcZVh7Y/O9JHqku2xXHA7GoIXKgfjJoa4sTg73L9+4CS5JMmGwyRlpzvE6djdEevqK11At/h8md+aOhjfrxeYVG2iMfg9POtJsOJ+BMtD8PTVgwTliMbfglOHlC9V8fOTnD4H1mTOTsoACgEonhh9pnfe/qiBJG2rZrkaStcJnKOYzdRmxLmXxF1rUPIMK/42+YX0+YVSZ9kih+CjfvuKZ1xTzlf+Nfbpmb8CcTJM8EKp8F3j2/eSa4uyYvkHvrYMWjThl1bEE5CO8kAqAChZo6vOcC5lU+yDZx08gLHISFH7MJqotKy3RHv3A4Om91jFaA1Mz5xIVEQ/URuVw5Xc9oZlsh2zCSNWRSdxmb51xfGQuVQmyqSC5Mll2HAyaNoFu+KqcPP9C526o0kFiy6SYyCPei+vPE+Drb/ksNyqUyLZ+hcIdyp5pTe+SUu+hBgOhnAcxmpWIjh2qhj8Q2zWknV3dFkAeSrMQ+WRR8groaL1EE4VFVv0RGSnxoTiHyg7GIpQMhG1GN+4CqrZzcKbf+cp2ZKvKhIzcag+MPaBZSBVL1daGadTUltb7IpetFlvVZxdve0TcXJ0b2Eayim0/lNVRzSK8SpIPtx23D5ayCawwJZF9St3ltgGdMwmDTsjY5Pj7SD0lAp9riQKAq3fAlW/24LOkIDUdA9rYLnwGNCzm54GR9rKKpSeXNoXefwwtFE1PtI9iQF399wF1Ln+Gbn4UY0aCRzpNSvGWL28XMgYyOHhCRbavNo6/RG93/BKgYtLj Pj5g6hZ5 h8rnvmE9jr3X1OZpHaFEzlDIq/T495z8wCm+Thh34ePHPpGd3FmRtaF74QA== 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 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).