Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11870138rwd; Thu, 22 Jun 2023 20:59:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41VFF9bcIkruWNkjZI5ie2Z5/VcG6zbBkJMGx4ws8VA1nBqlb0fonq2n/HwsKsTG1S5hVE X-Received: by 2002:a05:6808:1987:b0:3a1:9540:feb1 with SMTP id bj7-20020a056808198700b003a19540feb1mr2256007oib.14.1687492768956; Thu, 22 Jun 2023 20:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687492768; cv=none; d=google.com; s=arc-20160816; b=HkpIo41wBrbLDq7l7JO6gBaCDTEHU0s+IKsxsKzxb6LLy2dp10nSFFO9ZdNw5cHB5t Pw21WU/U8JpMihX9nxLAk/6n8/xkgllpvYuVx2/bHWkEAfbeFmcjqUuOeNPOeyzugJZJ DHW1mbB2mb/1ZqOJRG0RSKG1IgXPGpYyrgtRY6FOsMB3um5ITY7tFvO8vaZwpxZ32grQ Pjw5/HgVgrM6lv7q/D2OaKyHC5s3qoL78xIuSCZ9nBYdHzb7dXKZ0N7g73EhJyzEAM5N B2Afkk2SmPpuuhaJyVTIU2ba3wmxl2lFuPAJLa9Mxs2ZouqbU+dp9m6atKhueBHYDY6P 9CmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=nQCkd4lI+x6yZWQGbIGjk8nvglDFNi+aN+K8MOcwH6c=; fh=2CG14JwpM6eHq2Oc1blPVokPMUFjHf8iWfjorz+iBMY=; b=C7cf5Rwalvvu4KqolVdXqBnvdV2zLiBZy8TJ0HpM4B+406vKbHQMoTE1SY61UlrN8S ju6rGNPAWcCII3Efk5SD4Rf6ANO1tlHjSsGa7BlvMYUZobftKRxyrKY2xvXbLe5UqCJA fvzo+TsGF8fIOgu9zDPwRqbPZ179vkHAGq3Atgfxlw0kXUx9+oxYp9Qjm+6kCUJyvuCR oO8t607EBmK2f8tzqvx0zI1JGGrvXS1jU8H934QnfhE94gAy0PdEtEXNjtKJldeJl9dV FLrVraFmobbwlnnQ47a4ealLgA1BUwvVEGosmSMwRnaJ2D/tbdwxibfD48/O20YMXYYv iEMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=obkzvxCG; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j23-20020a17090aeb1700b0025d54872955si971141pjz.183.2023.06.22.20.59.16; Thu, 22 Jun 2023 20:59:28 -0700 (PDT) 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=@gmail.com header.s=20221208 header.b=obkzvxCG; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230330AbjFWDjH (ORCPT + 99 others); Thu, 22 Jun 2023 23:39:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbjFWDjE (ORCPT ); Thu, 22 Jun 2023 23:39:04 -0400 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFD2510F4; Thu, 22 Jun 2023 20:39:03 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id 6a1803df08f44-6300f6ab032so2275386d6.2; Thu, 22 Jun 2023 20:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687491543; x=1690083543; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nQCkd4lI+x6yZWQGbIGjk8nvglDFNi+aN+K8MOcwH6c=; b=obkzvxCGresnf5FRfVrvj4b/znqPUmGMMwKvIvfk8JFNu1deF5iG2IClXFSs/hqBes 0DchAnN9jcxuJK+1+ZKd23RORLAtCB1aaCRRAW/OhJcfqCqUQNLBzTBpbxJmpuWbKfjS GHJW8WsTLXwJYS5PMKJOMqwGF/WhlRObHMiD0r0si8DOzKdhQ3DRjzuP54tE28VCyLvh LV9mOcap4BQfgiSa4vCLx3tJr5yWQgnZ2UsTStLz9NxYkxX8IS7oFayaE3MrbO0dEpB/ K0gDAaORiA1jbA+zNdWb4SjSRPyF9Y1hEdIFkFam1bjGmw9MYsZEQu4LxQURWeFd5nOn uaSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687491543; x=1690083543; h=content-transfer-encoding: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=nQCkd4lI+x6yZWQGbIGjk8nvglDFNi+aN+K8MOcwH6c=; b=ZfJrInugmkS/UKtvFOlT79aPxal+88tkbnvrasUdO+GOBbGPPJJJ2jMdcDXCRbLuBe /xy+dLj90SvvjkBFBhmliS5sjwTd60+3VzF1n2qt9xGpJZp+lfS4zjJ7dzR8WNeq3Xi8 p9LcnC1v+HtWvLXjKLqIreDv9YxYSFW5rHqQz2W8ayMR5sP1rN8PE7qBI5zNQGdKV0Ax IQwrNKkdURvrnI6wketgPOucEDQrUHP0dp/MB4KBtpGXoF4BAdRqKy5yakGdPXbDTIVm Q1VTFI/3Kktk/R3MeInRbcQZupZKoFmLvmI2B8S/T6vjz8aTI6asgM/s0/dSS3ikXhy2 bZeg== X-Gm-Message-State: AC+VfDw2TN1V+6uv5bzAbj+dVg8oKFrfG7i09+o86M08c3V4gG4Jfvye aPnRUfpwyHQnyMw5F3Y/dreR6fsdQ8Ui4yrO3F4= X-Received: by 2002:a05:6214:29c8:b0:62d:f35c:a477 with SMTP id gh8-20020a05621429c800b0062df35ca477mr28990227qvb.1.1687491542761; Thu, 22 Jun 2023 20:39:02 -0700 (PDT) MIME-Version: 1.0 References: <20230620144618.125703-1-ypodemsk@redhat.com> <20230620144618.125703-3-ypodemsk@redhat.com> <10050BB1-15A4-4E84-B900-B21500B2079B@gmail.com> In-Reply-To: <10050BB1-15A4-4E84-B900-B21500B2079B@gmail.com> From: Yang Shi Date: Thu, 22 Jun 2023 20:38:51 -0700 Message-ID: Subject: Re: [PATCH v2 2/2] mm/mmu_gather: send tlb_remove_table_smp_sync IPI only to MM CPUs To: Nadav Amit , Jann Horn Cc: Yair Podemsky , mtosatti@redhat.com, ppandit@redhat.com, David Hildenbrand , "Russell King (Oracle)" , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Heiko Carstens , gor@linux.ibm.com, agordeev@linux.ibm.com, Christian Borntraeger , svens@linux.ibm.com, "David S. Miller" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Kees Cook , "Paul E. McKenney" , frederic@kernel.org, Will Deacon , Peter Zijlstra , ardb@kernel.org, samitolvanen@google.com, juerg.haefliger@canonical.com, Arnd Bergmann , rmk+kernel@armlinux.org.uk, geert+renesas@glider.be, linus.walleij@linaro.org, Andrew Morton , sebastian.reichel@collabora.com, Mike Rapoport , aneesh.kumar@linux.ibm.com, "the arch/x86 maintainers" , linux-arm-kernel@lists.infradead.org, linuxppc-dev , linux-s390 , sparclinux@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Wed, Jun 21, 2023 at 11:02=E2=80=AFAM Nadav Amit = wrote: > > > > > On Jun 20, 2023, at 7:46 AM, Yair Podemsky wrote: > > > > @@ -1525,7 +1525,7 @@ static void collapse_and_free_pmd(struct mm_struc= t *mm, struct vm_area_struct *v > > addr + HPAGE_PMD_SIZE); > > mmu_notifier_invalidate_range_start(&range); > > pmd =3D pmdp_collapse_flush(vma, addr, pmdp); > > - tlb_remove_table_sync_one(); > > + tlb_remove_table_sync_one(mm); > > Can=E2=80=99t pmdp_collapse_flush() have one additional argument =E2=80= =9Cfreed_tables=E2=80=9D > that it would propagate, for instance on x86 to flush_tlb_mm_range() ? > Then you would not need tlb_remove_table_sync_one() to issue an additiona= l > IPI, no? > > It just seems that you might still have 2 IPIs in many cases instead of > one, and unless I am missing something, I don=E2=80=99t see why. The tlb_remove_table_sync_one() is used to serialize against fast GUP for the architectures which don't broadcast TLB flush by IPI, for example, arm64, etc. It may incur one extra IPI for x86 and some others, but x86 virtualization needs this since the guest may not flush TLB by sending IPI IIUC. So if the one extra IPI is really a problem, we may be able to define an arch-specific function to deal with it, for example, a pv ops off the top of my head. But I'm not a virtualization expert, I'm not entirely sure whether it is the best way or not. But the complexity seems overkilling TBH since khugepaged is usually not called that often. > >