Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2128143rwl; Thu, 6 Apr 2023 06:18:23 -0700 (PDT) X-Google-Smtp-Source: AKy350aJfUHyMwZm+PX0AmazdXuZYWbNCa52CU07LNT4VNTZijbo2h5vOCHeysrodis1I8Bc46vj X-Received: by 2002:aa7:c945:0:b0:502:74c0:dcce with SMTP id h5-20020aa7c945000000b0050274c0dccemr4968799edt.31.1680787103392; Thu, 06 Apr 2023 06:18:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680787103; cv=none; d=google.com; s=arc-20160816; b=NauoNQDdhv/aYAbwiCwL/ZwQjsRbjul8FQfn6NCFVpU6274wTYI+55G6OcaEbFjsr/ S5OPk7CD/4rjIeuQ0Odc9pWDOxXfzlLpf/0EDZXNBCVyJSQYZ5ZNMcudGdU2qXPXZw8A yDnFdE7c9KGBOfqnfSBtqr6gQ7cDqD71LM3APCoZVS9YiCnUzBGgbnhZemENFlHaLNaH Yt0rvzZLv5v+/g5trvj91qLi9SeBoJDVQa5Ctepay9e78F/29LBI9bManppgkq0zGhkW 0VnNE1Tpzlsgo+MUoU1aJhIdB3n3D/cspa69EepnNboCm2VXx4V0NN15/Holdu1mBrDL cyMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LyLWq4qOx1xU0bxV6bHK7gb5g8imneWyvQWEYXMsdJw=; b=nuus9/2sRRTlgVaOz3Z0eRE4w2xB+WNWUTvl+kwOp2EruULVAvR6TAO5SU/UQZkmlX JZrLWy3SWseeN0K8C4lM269LkBemNAFN4yGcurIl+qAwVrePrbJB67HCOw3p21z0eI90 ZLxxa+RZhs2Qzc5xzLOsCFRw1SWxZzS3Hz0MFfv1puuevy6Ys8mguk/Qks9tKJEW8bbS YahfcdWLf7SctI0JYlFC2FaKyYv26XfVMZkpKgr6I7aPGkFDBRVG7hnp8rhrWxJO+Brd jCzy/KWTRQOQZwx3WtMuz3oyC9TXfFJXPJYQ1wGMO9nkOP/JkfJLUc4iFejNYr0Sl3SN BW2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=COG5BabD; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w25-20020aa7da59000000b004bc45c5440esi1085221eds.67.2023.04.06.06.17.57; Thu, 06 Apr 2023 06:18:23 -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=@redhat.com header.s=mimecast20190719 header.b=COG5BabD; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237098AbjDFNRl (ORCPT + 99 others); Thu, 6 Apr 2023 09:17:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229817AbjDFNRk (ORCPT ); Thu, 6 Apr 2023 09:17:40 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3313559FA for ; Thu, 6 Apr 2023 06:16:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680787018; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LyLWq4qOx1xU0bxV6bHK7gb5g8imneWyvQWEYXMsdJw=; b=COG5BabD9J5sU2n6dBrFzLjHIRP5NC6tQDE167skwBSAq3NwYkmiC/8ghPoyxHThRqLQ0w bk8MmQnbQYF4pU8CR1jrDQx+OoqMMF5oryqAteLMhyS1miX1GNXBl8J3fPZaVdQ3jzgdpU xs9EIaeA5tBryfqM6cSZZwhGUBnhDbw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-612-LTw34yIZO-qtviR3tWXTcA-1; Thu, 06 Apr 2023 09:16:57 -0400 X-MC-Unique: LTw34yIZO-qtviR3tWXTcA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2EF4B857F81; Thu, 6 Apr 2023 13:16:55 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86155C1602C; Thu, 6 Apr 2023 13:16:54 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 8BB9E41306EC9; Thu, 6 Apr 2023 09:38:50 -0300 (-03) Date: Thu, 6 Apr 2023 09:38:50 -0300 From: Marcelo Tosatti To: Peter Zijlstra Cc: Frederic Weisbecker , Yair Podemsky , linux@armlinux.org.uk, mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, davem@davemloft.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, will@kernel.org, aneesh.kumar@linux.ibm.com, akpm@linux-foundation.org, arnd@arndb.de, keescook@chromium.org, paulmck@kernel.org, jpoimboe@kernel.org, samitolvanen@google.com, ardb@kernel.org, juerg.haefliger@canonical.com, rmk+kernel@armlinux.org.uk, geert+renesas@glider.be, tony@atomide.com, linus.walleij@linaro.org, sebastian.reichel@collabora.com, nick.hawkins@hpe.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, vschneid@redhat.com, dhildenb@redhat.com, alougovs@redhat.com Subject: Re: [PATCH 3/3] mm/mmu_gather: send tlb_remove_table_smp_sync IPI only to CPUs in kernel mode Message-ID: References: <20230404134224.137038-1-ypodemsk@redhat.com> <20230404134224.137038-4-ypodemsk@redhat.com> <20230405195226.GB365912@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230405195226.GB365912@hirez.programming.kicks-ass.net> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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, Apr 05, 2023 at 09:52:26PM +0200, Peter Zijlstra wrote: > On Wed, Apr 05, 2023 at 04:45:32PM -0300, Marcelo Tosatti wrote: > > On Wed, Apr 05, 2023 at 01:10:07PM +0200, Frederic Weisbecker wrote: > > > On Wed, Apr 05, 2023 at 12:44:04PM +0200, Frederic Weisbecker wrote: > > > > On Tue, Apr 04, 2023 at 04:42:24PM +0300, Yair Podemsky wrote: > > > > > + int state = atomic_read(&ct->state); > > > > > + /* will return true only for cpus in kernel space */ > > > > > + return state & CT_STATE_MASK == CONTEXT_KERNEL; > > > > > +} > > > > > > > > Also note that this doesn't stricly prevent userspace from being interrupted. > > > > You may well observe the CPU in kernel but it may receive the IPI later after > > > > switching to userspace. > > > > > > > > We could arrange for avoiding that with marking ct->state with a pending work bit > > > > to flush upon user entry/exit but that's a bit more overhead so I first need to > > > > know about your expectations here, ie: can you tolerate such an occasional > > > > interruption or not? > > > > > > Bah, actually what can we do to prevent from that racy IPI? Not much I fear... > > > > Use a different mechanism other than an IPI to ensure in progress > > __get_free_pages_fast() has finished execution. > > > > Isnt this codepath slow path enough that it can use > > synchronize_rcu_expedited? > > To actually hit this path you're doing something really dodgy. Apparently khugepaged is using the same infrastructure: $ grep tlb_remove_table khugepaged.c tlb_remove_table_sync_one(); tlb_remove_table_sync_one(); So just enabling khugepaged will hit that path.