Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp637282rwl; Wed, 5 Apr 2023 05:56:26 -0700 (PDT) X-Google-Smtp-Source: AKy350YCHJ1Ro/T8WQccMhl+FWDIIeo8TL9oc4/pZtf8FVK8Tsc+onVIT5Q6fQsSx6LCQlpsA9cg X-Received: by 2002:a05:6402:1001:b0:501:d43e:d1e5 with SMTP id c1-20020a056402100100b00501d43ed1e5mr1774985edu.2.1680699385788; Wed, 05 Apr 2023 05:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680699385; cv=none; d=google.com; s=arc-20160816; b=tLu64Dg4zS0mF/6ftspOGQGu+y73qH2z6Lj1PDJTwdiJp7q+Ud48e0arJ3K3+hDXOj eKYvxlFkZBkB5YTHXKZ4rpYcM+TubR1mzwPLmBE914Jt3Wq/JAOYZ1VcqbiFWMtXApD4 os560uqfR0lWogVhFUJvSS1HgD3a2T6Q+F6dqK0jHhvdOVMLJgMRBF411qEESVhovei/ CB2606Hm9xQod/eLxxuuYAyhotPIxSX0g51qTYvH/VlOeGOaCLDgfM5D0f4kEbhjVuUg bAvJLB3tdAACqCbJel0esVG+fajkqrq6S2/pbcKMTRaVYbiI9fii3Qr1kEmzLZHPCY6O pDKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=rJlvbrDO3MZW25EtVUfp0HoO311UYJgGKtfX/KEqF/k=; b=LxpyYC0yHB8TU8nlhSkb19dv+7KS/mc+IWPi1gmo/64yZxwUDifgK42Fw0Fw4qIxWw TSaFE5KhqUBfgpXGlGh3K40UT1wAOZJ7lVjf/JKV7OUIZlLfQjPswP9M0iexicy6J69p MR/wg2RuE6zqmocH6SlI1ZAssM1nLBRfULOCdQSHF1TYI0OyQS//hzOqgBmbP9Bh8HAv 1xb7Y88YQMnNtx8p/VuKjHTbMRt2Pe1Ai9ZXcXWQcUif2FsQQVl7kjc/nStsy3Hj6qqr MHO0iUd+KqJw8iaI0lavO2nKMvHSx3cSRfVDT1aDTf5WQYHxfUOydWCxvDeNSkOsOwEX W71Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GER116tg; 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 b10-20020aa7df8a000000b004fba129c19dsi1344024edy.597.2023.04.05.05.56.01; Wed, 05 Apr 2023 05:56:25 -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=GER116tg; 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 S237636AbjDEMp6 (ORCPT + 99 others); Wed, 5 Apr 2023 08:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237282AbjDEMp5 (ORCPT ); Wed, 5 Apr 2023 08:45:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 221482D44 for ; Wed, 5 Apr 2023 05:45:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680698711; 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=rJlvbrDO3MZW25EtVUfp0HoO311UYJgGKtfX/KEqF/k=; b=GER116tgb+iYLrIT7d4YCy70CvkCC3ZTYBKLxajJxbZgXuyKM2JcZML6stGxqYHRr9T3HP v8nxW5K3mkeZs7BYaINTyAH6JCw+5alZIbchu93T79G7V2a+W0U8fV0muR1w1xJg8nfw83 Gk8E7tl2N3FaU5OmliSluZx/6RQwOf8= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-301-DFs0-FOWN7KHWpoEkGRWkA-1; Wed, 05 Apr 2023 08:45:10 -0400 X-MC-Unique: DFs0-FOWN7KHWpoEkGRWkA-1 Received: by mail-qt1-f200.google.com with SMTP id x5-20020a05622a000500b003e259c363f9so24239362qtw.22 for ; Wed, 05 Apr 2023 05:45:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680698710; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rJlvbrDO3MZW25EtVUfp0HoO311UYJgGKtfX/KEqF/k=; b=qlNUk8eaEf44G/qbKAXPc0sRJ+MW2nX8Q4zjbnw3LYpnNFoYqZjq6IGSHkFlj9JAqG +udePzJQAj92oOmXFxpDVrxZLY8rIw/oXygrGWyhu/ogG7t+6pHQtomU9jnGXqzqH+XW WpsmHzWw2z2TZn4eHX/yFrGc29LnMyxCc6gFUlzpapWkuz0iT7Wev10zKmlpUDC4H8dp +3ocqCfSUFA46FGCScNDUsqE+k5jeQeyiKTxePDSTC3f7yqNB4SDyVjyZRhFrGu2h0Rp Xz0JyDLIoCsCyLrAEX6ql/Eq6N3K94iKf0BoB7yCLNPvXMWE/QWxDwOhisrE/ca8HVo3 7gLg== X-Gm-Message-State: AAQBX9dPqJzUriE3oBLcS9m4B9WLIwSzr1He+egdX2pLvJcgUICY5NmB QmzKF2AbAnlrnTDs+Q4RdKVifE7mnyJaMrKuH5L490w9M+REmuy1WS+SWqHvwXve6DWlR6mUm/J jjigYvSPjdDQiazi3/MtUWksJ X-Received: by 2002:a05:622a:1716:b0:3e4:eb03:687d with SMTP id h22-20020a05622a171600b003e4eb03687dmr4303530qtk.44.1680698709722; Wed, 05 Apr 2023 05:45:09 -0700 (PDT) X-Received: by 2002:a05:622a:1716:b0:3e4:eb03:687d with SMTP id h22-20020a05622a171600b003e4eb03687dmr4303502qtk.44.1680698709447; Wed, 05 Apr 2023 05:45:09 -0700 (PDT) Received: from vschneid.remote.csb ([154.57.232.159]) by smtp.gmail.com with ESMTPSA id t186-20020a37aac3000000b00746b7372d62sm4415939qke.27.2023.04.05.05.45.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 05:45:08 -0700 (PDT) From: Valentin Schneider To: Frederic Weisbecker , Peter Zijlstra Cc: 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, mtosatti@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 In-Reply-To: References: <20230404134224.137038-1-ypodemsk@redhat.com> <20230404134224.137038-4-ypodemsk@redhat.com> <20230405114148.GA351571@hirez.programming.kicks-ass.net> Date: Wed, 05 Apr 2023 13:45:02 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain 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 05/04/23 14:05, Frederic Weisbecker wrote: > static void smp_call_function_many_cond(const struct cpumask *mask, > smp_call_func_t func, void *info, > @@ -946,10 +948,13 @@ static void smp_call_function_many_cond(const struct cpumask *mask, > #endif > cfd_seq_store(pcpu->seq_queue, this_cpu, cpu, CFD_SEQ_QUEUE); > if (llist_add(&csd->node.llist, &per_cpu(call_single_queue, cpu))) { > - __cpumask_set_cpu(cpu, cfd->cpumask_ipi); > - nr_cpus++; > - last_cpu = cpu; > - > + if (!(scf_flags & SCF_NO_USER) || > + !IS_ENABLED(CONFIG_GENERIC_ENTRY) || > + ct_state_cpu(cpu) != CONTEXT_USER) { > + __cpumask_set_cpu(cpu, cfd->cpumask_ipi); > + nr_cpus++; > + last_cpu = cpu; > + } I've been hacking on something like this (CSD deferral for NOHZ-full), and unfortunately this uses the CPU-local cfd_data storage thing, which means any further smp_call_function() from the same CPU to the same destination will spin on csd_lock_wait(), waiting for the target CPU to come out of userspace and flush the queue - and we've just spent extra effort into *not* disturbing it, so that'll take a while :( I don't have much that is in a shareable state yet (though I'm supposed to talk some more about it at OSPM in <2 weeks, so I'll have to get there), but ATM I'm playing with o a bitmask (like in [1]) for coalescable stuff such as do_sync_core() for x86 instruction patching o a CSD-like queue for things that need to pass data around, using statically-allocated storage (so with a limit on how much it can be used) - the alternative being allocating a struct on sending, since you don't have a bound on how much crap you can queue on an undisturbed NOHZ-full CPU... [1]: https://lore.kernel.org/all/20210929152429.067060646@infradead.org/