Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2978850lqo; Tue, 14 May 2024 16:04:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXU4VrN+eHrQ1hdr+Jez6WWGpLMg1j/A5x3egmeRkE28orOdqRKLiDNF0uWvdkJqbQMBAQq/OXW6Yd3r5L4d8XiEVEA0bpUgGREjVK91Q== X-Google-Smtp-Source: AGHT+IGAsSZpC735BfZeud3bO+1i4uZHPJoEncEjW5z2KB2/wwtZQ6QN+bA8G30xRfDegawrJtNc X-Received: by 2002:a05:6214:3c8f:b0:6a0:b014:c880 with SMTP id 6a1803df08f44-6a1679a7624mr246362786d6.29.1715727895356; Tue, 14 May 2024 16:04:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715727895; cv=pass; d=google.com; s=arc-20160816; b=HCZE0UY4HGbj/yEYjyUBryGXUsGjnk7zG+7lcPmFZuk3I0CmLFjL3CtsjX37od2t73 WOcf7eNy/sR9M56pwnv4ky5kaKDH8mUE9obg4DHDhXxihXLZtim7N1NMYFTM93jykDoB IesrX7ASId4d8KWqNUBVglnQY8khxD3X3Yvj92pHh05udAnVl+nWRNUYLTeP1kxQaHkH HQyZdAf2aa2ocBBVwrDTNtyyzR/DH63jP3qS7W0nECB1eE9ettM0tPRIOp/3dSEVBIKF SS9bgyPLGPd+yOiYAb4rqYfDB64ydY7PR9i/8HTEzNBnjIgTc2YEvvLA5Mlc7t68yHs5 n/jA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=BFDv0vTXoc2NMBBi7ioc7QN0hBYwdSMxX3SrQtikH04=; fh=w0JXPK8QBSyBdNcoZt7UvypYsL4Kpyo6b4xEsZVjVeo=; b=CdX1bTE8d6QN42CSRRd8vRJ4bjVxCwWj1coiQ43FvOyYs3fSbP2WvjRWC+ziQmohZj 5ifnKTECgIb3DKKbFpuTwLLY/7ckymB7lYrxS49fkRp9innfEFmX9h3RhpJjHirr9rjB bYJPf+E5NzsqsOEPeH8w6qF03Vvm8AKM75e8GiHg+fNdOLz9T9odqGN12BAKC4c4+AQi 6+qTO9Cvc7pJdK+rTHpncFc1ANMmbp7F5oa80w5QDzwAxn4An6riGQUkQWK3fj0uKewk KOBYVMBSdCGGHS0YDicvVhv/vS9FK2L5dgJxUHllnWFIbA8KUFIDesTg2oiN8ViiLNmb 0/NA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VfRCS1xE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-179252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f1d6d48si133210266d6.48.2024.05.14.16.04.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 16:04:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VfRCS1xE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-179252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 18F771C20BAF for ; Tue, 14 May 2024 23:04:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B4E7A182C9F; Tue, 14 May 2024 23:04:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="VfRCS1xE"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="9yUGQPaf" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56C12181D1B; Tue, 14 May 2024 23:04:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715727885; cv=none; b=MdPWXNRNxWRVXBm9LUL7ehRcsZz22Qxoygg41byuukxEkJy5J7FOotUY1+u8pRyWFdtYCEBE4brCKn6oQkxch+4+BBBvNv25S9ZP7G2w8GCBqGhNWY8no49xpoKWHoF6Fv2ZLKj/U56reN0uFZ5dcpWnyNarXixF7IN9h6vXH8g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715727885; c=relaxed/simple; bh=gCqjA9RatKnkSLjN8bz5VWEWDMhZs/6qSocvM+g3FVw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=gN8IJk1y3FKZhYZ9d2WLhXETmQGnoIJYupby92sVg8mnPalh9sb3IuyFoj9SsiaJF/ZKI+zRCj0HHJUdn5XMYFjg8oEvFtD3SRyt8u4U5XJIT+ASKCG7kRdiLeMOS0QammJBzF01jvyfap9Epn4D9YW7gd86DP5Qr47a48MQBw4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=VfRCS1xE; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=9yUGQPaf; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1715727881; 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=BFDv0vTXoc2NMBBi7ioc7QN0hBYwdSMxX3SrQtikH04=; b=VfRCS1xEuVn0TC+V8CPKMMpTg3JuFGmi1jBVjByv6MhGaNzBh4z6C7kA+3FARjJ5etqwvK fQFirRS8V04Wmofl8iONlOluxowpu2mA9JNjAhhaBJFL6p4lhi/vcHRfT/XaaZj3itFEA4 z+kNwnn7Nz5Y9g3APngnjKsXEib0+hJbKOr3iD2sXaVoWfPuO8a2+6wcafJvW+qe/B+1tL o2Havzb+6ZWtr5Z96r7wLQOZNJkNj8/PCkKccvigrqIBHljgUsqLIM8PduSQVSkV4bi+1l Uwig64GlLyIGqppecTYAtaiwl1kJoTmL38MAcZ55SieyQknnd1VcNYvTR8ooGQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1715727881; 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=BFDv0vTXoc2NMBBi7ioc7QN0hBYwdSMxX3SrQtikH04=; b=9yUGQPaf3z81Jk03mDqBPEV01Un1HjiWGSXjawU0tNT7Ltp0VCHiBBhc/2hgLDnJ7ogT/F Rnt3aFPXMmAugjAQ== To: Adrian Huang Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jiwei Sun , Adrian Huang Subject: Re: [PATCH 2/2] genirq/proc: Refine percpu kstat_irqs access logic In-Reply-To: <20240513120548.14046-3-ahuang12@lenovo.com> References: <20240513120548.14046-1-ahuang12@lenovo.com> <20240513120548.14046-3-ahuang12@lenovo.com> Date: Wed, 15 May 2024 01:04:41 +0200 Message-ID: <87h6f0knau.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Mon, May 13 2024 at 20:05, Adrian Huang wrote: > @@ -461,7 +461,7 @@ int show_interrupts(struct seq_file *p, void *v) > { > static int prec; > > - unsigned long flags, any_count = 0; > + unsigned long flags, print_irq = 1; What's wrong with making print_irq boolean? > int i = *(loff_t *) v, j; > struct irqaction *action; > struct irq_desc *desc; > @@ -488,18 +488,28 @@ int show_interrupts(struct seq_file *p, void *v) > if (!desc || irq_settings_is_hidden(desc)) > goto outsparse; > > - if (desc->kstat_irqs) { > - for_each_online_cpu(j) > - any_count |= data_race(*per_cpu_ptr(desc->kstat_irqs, j)); > + if ((!desc->action || irq_desc_is_chained(desc)) && desc->kstat_irqs) { The condition is wrong. Look how the old code evaluated any_count. > + print_irq = 0; > + for_each_online_cpu(j) { > + if (data_race(*per_cpu_ptr(desc->kstat_irqs, j))) { > + print_irq = 1; > + break; > + } > + } Aside of that this code is just fundamentally wrong in several aspects: 1) Interrupts which have no action are completely uninteresting as there is no real information attached, i.e. it shows that there were interrupts on some CPUs, but there is zero information from which device they originated. Especially with sparse interrupts enabled they are usually gone shortly after the last action was removed. 2) Chained interrupts do not have a count at all as they completely evade the core kernel entry points. So all of this can be avoided and the whole nonsense can be reduced to: if (!desc->action || irq_desc_is_chained(desc) || !desc->kstat_irqs) goto outsparse; which in turn allows to convert this: > - for_each_online_cpu(j) > - seq_printf(p, "%10u ", desc->kstat_irqs ? > - *per_cpu_ptr(desc->kstat_irqs, j) : 0); into an unconditional: for_each_online_cpu(j) seq_printf(p, "%10u ", *per_cpu_ptr(desc->kstat_irqs, j)); Thanks, tglx