Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1324179ybi; Wed, 3 Jul 2019 13:35:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMuhuJDDfetmXifbdSCOJTmAQL1/CKKk+QgpCNKo/hpvoCUaXmW9r//Ja0w9Vz1UsS1ueX X-Received: by 2002:a63:593:: with SMTP id 141mr37605957pgf.78.1562186151778; Wed, 03 Jul 2019 13:35:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562186151; cv=none; d=google.com; s=arc-20160816; b=e0RrgI95qwNDLVDT4L8XEtkx6gfUh7gR+2LeV9QRjnWRlrCWNo7ealxfE9sNp4Nmtv a4UzK/k/bNXaGD0n6Y+CvAlekfA9To0rry4UP4VSASGe4+ReFBUCqlK4AVJKdGTwuihv YIF/Ysvt/vyIXKF9Nn7zEEORfguF9F0nmY6uw4NmD2hxkrfcBBYGRRA3G4VezMhjOo3u 0uncQkuXJ53bcRJzFjwvsxQdH7up+n+2rDW97ESaEk290BT1FbpfmFFRB91GX54Ubl6q 7j5TVENf6HB651PYnPOWfPT23WyzKR2+rUjAkfiNVet/wW4VxhF+NCNyFT5Q+e8PmaOw hH8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=z1tQ6ORzhsmOfmbXOzzjos4QrfOPC7F4+ar6RE4XDLo=; b=JwoiXaBlsXgseWPxpnvLrNohSO2cuRESdWWfiT112uL1+PZW+W0sQJSIw0HgCFe4wD 5E8zgrLkbWD4RVHPZ63c37iJ0kdNakp7QWUiUGIozCIVFWrRtqHhFNMlz3Xhf0mwPgz2 AffyQgSv96Ta5+2dpZlmvEu31W4fjJcbFX7hV39b+UOlA+IpZmLht84v9ng+b5hQ65j3 wY2yrYdiKHhHfXY/1SGZ+NSpxu7wGWh/f+Vve3VPEjEly4Zo/WMiwPYpyiuYVzTPh/yE Stv3ubPwgUKycKzrnNiSYsidTX7P9yo9BTi0GYawcvbR1m0Rvt1GdbITqZTk8jm5mVMH hmnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y92si3144186plb.209.2019.07.03.13.35.37; Wed, 03 Jul 2019 13:35:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727417AbfGCUej (ORCPT + 99 others); Wed, 3 Jul 2019 16:34:39 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:56122 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726739AbfGCUeg (ORCPT ); Wed, 3 Jul 2019 16:34:36 -0400 Received: from pd9ef1cb8.dip0.t-ipconnect.de ([217.239.28.184] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hilxa-0008FU-Gu; Wed, 03 Jul 2019 22:34:34 +0200 Date: Wed, 3 Jul 2019 22:34:33 +0200 (CEST) From: Thomas Gleixner To: Nadav Amit cc: LKML , "x86@kernel.org" , Ricardo Neri , Stephane Eranian , Feng Tang Subject: Re: [patch 16/18] x86/apic: Convert 32bit to IPI shorthand static key In-Reply-To: <1DC35A28-DEBC-4A46-AC35-3AADD23AA40D@vmware.com> Message-ID: References: <20190703105431.096822793@linutronix.de> <20190703105917.044463061@linutronix.de> <1DC35A28-DEBC-4A46-AC35-3AADD23AA40D@vmware.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Nadav, On Wed, 3 Jul 2019, Nadav Amit wrote: > > On Jul 3, 2019, at 3:54 AM, Thomas Gleixner wrote: > > void default_send_IPI_all(int vector) > > { > > - if (apic_ipi_shorthand_off || vector == NMI_VECTOR) { > > + if (static_branch_likely(&apic_use_ipi_shorthand)) { > > apic->send_IPI_mask(cpu_online_mask, vector); > > } else { > > __default_send_IPI_shortcut(APIC_DEST_ALLINC, vector); > > It may be better to check the static-key in native_send_call_func_ipi() (and > other callers if there are any), and remove all the other checks in > default_send_IPI_all(), x2apic_send_IPI_mask_allbutself(), etc. That makes sense. Should have thought about that myself, but hunting that APIC emulation issue was affecting my brain obviously :) > void native_send_call_func_ipi(const struct cpumask *mask) > { > - cpumask_var_t allbutself; > - > - if (!alloc_cpumask_var(&allbutself, GFP_ATOMIC)) { > - apic->send_IPI_mask(mask, CALL_FUNCTION_VECTOR); > - return; > + int cpu, this_cpu = smp_processor_id(); > + bool allbutself = true; > + bool self = false; > + > + for_each_cpu_and_not(cpu, cpu_online_mask, mask) { > + > + if (cpu != this_cpu) { > + allbutself = false; > + break; > + } > + self = true; That accumulates to a large iteration in the worst case. > } > > - cpumask_copy(allbutself, cpu_online_mask); > - __cpumask_clear_cpu(smp_processor_id(), allbutself); > - > - if (cpumask_equal(mask, allbutself) && > + if (allbutself && !self && > cpumask_equal(cpu_online_mask, cpu_callout_mask)) Hmm. I overlooked that one. Need to take a deeper look. > apic->send_IPI_allbutself(CALL_FUNCTION_VECTOR); > else > apic->send_IPI_mask(mask, CALL_FUNCTION_VECTOR); Let me think about it for a while. Thanks, tglx