Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1829082pxu; Sun, 6 Dec 2020 08:41:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+miAm9NCNhPOIKvdUNnNxcTw6V6BSUDuncNgrsrQ8wYQAPOd5tSYcnsvt7E7tzucoJZHQ X-Received: by 2002:a17:906:358e:: with SMTP id o14mr15206002ejb.526.1607272894137; Sun, 06 Dec 2020 08:41:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607272894; cv=none; d=google.com; s=arc-20160816; b=qcUZo3Sf/G6AWh17EAiTieIMHd9yJ/f5AQNKedtV7uWYhxBcBkqUXh15S1aszEHNuB UIcTja0ji15rHCJw0sRpOO2/YSsGxT/i5Prd4lI2CcYmq4enKYT8I0Zz8PaRh9yVFFuN dYFhM9vIyLH+BTFjieeYcFMrRpTOMCN9vxuMiljvqD8i4/7GAwGLPE+rGmbc7SM+XK4c +kQz10ROLu0ah7KZywyyWKINiZuSwmyH7u9R+Tnwnhsibp5ffaGWSuQ/kncOjxe3IV7O ejutcV9uI4YlwuGH1CwkOqmo9RX/+pm+xmQb1iSTRoYLRw/mUAqf08iPp9zHbNI2pXqJ c2Vw== 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=orscdnWsxTjeOjrX4mZ7RlgaGlM/iHr3hxGeVG/5B5o=; b=aZBEnu6UhMgXIWypdM4QNIb7YJxaqBS4EmIiozQo25L0tTxIesrhubIQyW+19ngItZ H6nHm8UqHBnDIQQJtJbjcYdgf1lFBdPbutU8IDEkhwWR38BdAbvJp56VKKzUGpVoLc/O 4fcp4d0hg0qH6mjuVV6bLg6YskmKI6cMei6zM3UyY3uK+kf/KWp7K8gqcLY4zvLTzy9o rI1Vv+4yg+ME6r5zd4y6LIlGbk/cJsUIs8QJSBhMuVeLl9zKEpPdz3b5go5X3seIkT2F r+YVFnqxP0Ji58oDVScXUp+Dssj9HimPcO6CUivKHzJc5UAx8q0z+AytBmDJ6xmAfpaH L5kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=S9U+yLW+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=AksEazRj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x31si6797749ede.198.2020.12.06.08.41.10; Sun, 06 Dec 2020 08:41:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=S9U+yLW+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=AksEazRj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726043AbgLFQj0 (ORCPT + 99 others); Sun, 6 Dec 2020 11:39:26 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:58988 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726186AbgLFQj0 (ORCPT ); Sun, 6 Dec 2020 11:39:26 -0500 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1607272724; 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=orscdnWsxTjeOjrX4mZ7RlgaGlM/iHr3hxGeVG/5B5o=; b=S9U+yLW+RMD4XJ+DVjlUuG1Ta3scM6aUrIt7ysUfUnpo2Lk9yrcK1AlcgrZWgFWCtYoJTF VExnxFo/ryb4R7eRQEVwMsDGha92iA0oI81k+3gGLFB1nonwAisjC3/jKTSUf/nGy1d64W /i1uYHhHy/jPj6waERlxa7GsrP6eM2yH0numGnZwlG3dEBTbqM59AhAzaFX9Pkk1y9qak3 dhXHo9nnSGnB608LNXSZ0BSANnW+ESKfmIzwLrnY3Zp+ef11yigXhYhPrhNWafb4cMW6lM JyoZkKlnRO1jdjGoihuwGfLZqyXfJAFPDlho62hQLrm5QKAPcdCuOpSMM3JdkA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1607272724; 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=orscdnWsxTjeOjrX4mZ7RlgaGlM/iHr3hxGeVG/5B5o=; b=AksEazRjmD+yqQmgK8+KYrxZfIF8IEb97GXwe2YdDqzKrwXlC8Rc+QhlrKd/lk5AZdXYm6 zdJsYoIctUvQBdCw== To: Jerry Snitselaar , linux-kernel@vger.kernel.org Cc: linux-integrity@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Jani Nikula , Rodrigo Vivi , David Airlie , Daniel Vetter , Jarkko Sakkinen , Jason Gunthorpe , Peter Huewe , James Bottomley , Matthew Garrett , Hans de Goede , Peter Zijlstra Subject: Re: [PATCH v3 2/4] drm/i915/pmu: Use kstat_irqs to get interrupt count In-Reply-To: <20201205014340.148235-3-jsnitsel@redhat.com> References: <20201205014340.148235-1-jsnitsel@redhat.com> <20201205014340.148235-3-jsnitsel@redhat.com> Date: Sun, 06 Dec 2020 17:38:44 +0100 Message-ID: <875z5e99ez.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 04 2020 at 18:43, Jerry Snitselaar wrote: > Now that kstat_irqs is exported, get rid of count_interrupts in > i915_pmu.c > --- a/drivers/gpu/drm/i915/i915_pmu.c > +++ b/drivers/gpu/drm/i915/i915_pmu.c > @@ -423,22 +423,6 @@ static enum hrtimer_restart i915_sample(struct hrtimer *hrtimer) > return HRTIMER_RESTART; > } > > -static u64 count_interrupts(struct drm_i915_private *i915) > -{ > - /* open-coded kstat_irqs() */ > - struct irq_desc *desc = irq_to_desc(i915->drm.pdev->irq); > - u64 sum = 0; > - int cpu; > - > - if (!desc || !desc->kstat_irqs) > - return 0; > - > - for_each_possible_cpu(cpu) > - sum += *per_cpu_ptr(desc->kstat_irqs, cpu); > - > - return sum; > -} May I ask why this has been merged in the first place? Nothing in a driver has ever to fiddle with the internals of an irq descriptor. We have functions for properly accessing them. Just because C allows to fiddle with everything is not a justification. If the required function is not exported then adding the export with a proper explanation is not asked too much. Also this lacks protection or at least a comment why this can be called safely and is not subject to a concurrent removal of the irq descriptor. The same problem exists when calling kstat_irqs(). It's even documented at the top of the function. Thanks, tglx