Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1217407rdb; Wed, 6 Dec 2023 11:50:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IH968oKbcnNukl0LVGXjdOHx0z72mhAh+BBiGz75enxhqKIa7bf3tLGo9E6AtLIKQRBourt X-Received: by 2002:a17:902:d2c1:b0:1ce:5b93:1596 with SMTP id n1-20020a170902d2c100b001ce5b931596mr1293741plc.5.1701892255975; Wed, 06 Dec 2023 11:50:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701892255; cv=none; d=google.com; s=arc-20160816; b=XjJ+eQxImNCJ56zdVienB7o4NW8lYS+GiwMRfUCQSCwfeO4Agwux61tnKtVB0Yczts LnqOIDlwCHaf1sd7cnyJfM5mYL+bKrSBrtAEmzrNYMnSWSxQWJ96eMDSzrXyP/N/NH3S aVmJ1N1XMlJw2eMUe2MtaRlh+1vgHmKK6m+LKDfc6RWm994GpTijHzO3fGj3Z8ptpRtT LxslVTO86OKi8dqJHC7eTDin0aRGUmoEX82LV+XGwYr7HK3MOUvmTLzZ0mOAncnHsKPU rTnyLOKwTXdw1ux/pvrbSMqKRuUpxhG9Mo68bBp5MxCJ0cBQj12EnskLD5AVDCbBhFop UIgQ== 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:dkim-signature:dkim-signature:from; bh=9Dhk4+zCj2bSVdaz1f+DwCjhCz2nloe+08Lq1HubewE=; fh=yr+s8Jz1N7fmGYQyrbOz4BKp8sCkrIhu9fkvijfdKPQ=; b=i2qQAJ0BfKDUtxKKnX9CyuqLS9cjg1HcLCPPrh4vHMEwkz/AGDAad46bLKdWAFbCnv 6xB2DJH7VP9+I/ZU0gMEo1MkKgwMy+toZbdoZ8LIe0NNxduJ16tJQ0JXRX/3u2iDQQbn YZpdJ8p2U9Ka/LG6Eh6qg4TyJ7yvd0xAJMC/xNMjTe5lFAEeiz6pt+TplqjqU8rXBjDO 1geVDtlvZp11BjkfI0cyCuwH8J6oL1NTYfRfdJtxEZFp/2+iMb3os5swuHJIonl2cRRB cMYMyP165v5KYXERUGesJx95BIoBmicy9IGaziHMivFeIgKmguNOXMqjYZ86aD51vsG7 pYOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=v+urtsd1; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id u6-20020a170902e5c600b001d09013a13csi279387plf.329.2023.12.06.11.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 11:50:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=v+urtsd1; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id B82DC8029237; Wed, 6 Dec 2023 11:50:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379432AbjLFTuW (ORCPT + 99 others); Wed, 6 Dec 2023 14:50:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379411AbjLFTuV (ORCPT ); Wed, 6 Dec 2023 14:50:21 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50A2CFA; Wed, 6 Dec 2023 11:50:27 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701892225; 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=9Dhk4+zCj2bSVdaz1f+DwCjhCz2nloe+08Lq1HubewE=; b=v+urtsd1FTU9ZhLnfNMCVE4t5FHdgO9qBV8ZKGd9TpMRxHH/CEWRGbEy4B+0vGbO4suTau wkZdYWlpRePNfzJLQy0BJa0Rh5RCB44e1qerQk/+rqH2Kuxw1JD5rXXd38vUPHy/UaNfD7 CuB044qCEi9KUXNO4sdAO5+XlNWUFZr+rKjuYaZ45SI2Tr1BVqhKMx/ElfSYpG8SqoBKQl i5d9YiXVBrEUTzLU+M+B8U1EhdRdYXYjwtG+Inz5kqy416Tc2thKlKAt2VcOgX5ZLSfzzD av1/CKw9UkzTHaJ5OGGwop03VQVPbDBCweKuV1mA0BYPlLNulU2MD3+7iOvLag== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701892225; 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=9Dhk4+zCj2bSVdaz1f+DwCjhCz2nloe+08Lq1HubewE=; b=lGzQtl9x+ofH+fpqUAxl6pXbPHwEXsgGEzAYM7ctVOK90MAjAnLeYQaVWkrQ4Jcv/RiiwP ECczWzS12VAPxEBA== To: Peter Zijlstra , Jacob Pan Cc: LKML , X86 Kernel , iommu@lists.linux.dev, Lu Baolu , kvm@vger.kernel.org, Dave Hansen , Joerg Roedel , "H. Peter Anvin" , Borislav Petkov , Ingo Molnar , Raj Ashok , "Tian, Kevin" , maz@kernel.org, seanjc@google.com, Robin Murphy Subject: Re: [PATCH RFC 09/13] x86/irq: Install posted MSI notification handler In-Reply-To: <20231115125624.GF3818@noisy.programming.kicks-ass.net> References: <20231112041643.2868316-1-jacob.jun.pan@linux.intel.com> <20231112041643.2868316-10-jacob.jun.pan@linux.intel.com> <20231115125624.GF3818@noisy.programming.kicks-ass.net> Date: Wed, 06 Dec 2023 20:50:24 +0100 Message-ID: <87cyvjun3z.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 06 Dec 2023 11:50:40 -0800 (PST) On Wed, Nov 15 2023 at 13:56, Peter Zijlstra wrote: > > Would it not make more sense to write things something like: > > bool handle_pending_pir() > { > bool handled = false; > u64 pir_copy[4]; > > for (i = 0; i < 4; i++) { > if (!pid-pir_l[i]) { > pir_copy[i] = 0; > continue; > } > > pir_copy[i] = arch_xchg(&pir->pir_l[i], 0); > handled |= true; > } > > if (!handled) > return handled; > > for_each_set_bit() > .... > > return handled. > } I don't understand what the whole copy business is about. It's absolutely not required. static bool handle_pending_pir(unsigned long *pir) { unsigned int idx, vec; bool handled = false; unsigned long pend; for (idx = 0; offs < 4; idx++) { if (!pir[idx]) continue; pend = arch_xchg(pir + idx, 0); for_each_set_bit(vec, &pend, 64) call_irq_handler(vec + idx * 64, NULL); handled = true; } return handled; } No? > sysvec_posted_blah_blah() > { > bool done = false; > bool handled; > > for (;;) { > handled = handle_pending_pir(); > if (done) > break; > if (!handled || ++loops > MAX_LOOPS) { That does one loop too many. Should be ++loops == MAX_LOOPS. No? > pi_clear_on(pid); > /* once more after clear_on */ > done = true; > } > } > } > > > Hmm? I think that can be done less convoluted. { struct pi_desc *pid = this_cpu_ptr(&posted_interrupt_desc); struct pt_regs *old_regs = set_irq_regs(regs); int loops; for (loops = 0;;) { bool handled = handle_pending_pir((unsigned long)pid->pir); if (++loops > MAX_LOOPS) break; if (!handled || loops == MAX_LOOPS) { pi_clear_on(pid); /* Break the loop after handle_pending_pir()! */ loops = MAX_LOOPS; } } ... set_irq_regs(old_regs); } Hmm? :)