From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB341C433FE for ; Sun, 6 Dec 2020 21:47:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9716520857 for ; Sun, 6 Dec 2020 21:47:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9716520857 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3704289CBC; Sun, 6 Dec 2020 21:47:52 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4682989CBC for ; Sun, 6 Dec 2020 21:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607291269; 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=OTK3a2EpgqcMFsmrPHPH78wqX4JkIQW5zqkRG3GIknw=; b=Hj0gyByvgDu0Rq1YE5neEAyLLyFJ9SXYRtEusp6RezfuEcypIUlm/pX/rYommhUVMYC7Yp +1g3x5Qxf8Srx7/o4IN8BAO7H8kndoatyrx7Wx4RIRqnfGJQpII0441YlDtdBmhoIyzog9 HT9mEOqAgK5OQy6rhseB94qg75+UgYA= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-394-QjYCowtFOX-gfBX5wz0xqQ-1; Sun, 06 Dec 2020 16:47:47 -0500 X-MC-Unique: QjYCowtFOX-gfBX5wz0xqQ-1 Received: by mail-qk1-f200.google.com with SMTP id 198so10718094qkj.7 for ; Sun, 06 Dec 2020 13:47:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=OTK3a2EpgqcMFsmrPHPH78wqX4JkIQW5zqkRG3GIknw=; b=Dg8HKLpIqL0ztlx6/hXt2Q9HIOAT2ztRv+VkZiplJjwDvafUU/abjcmZIcNp/FhaZP s5MW7NbzDOLq3I77wWJ6ysbBNh4f0HOUMGmYdkRId5DG2MurApPavDwrOSBW88W8rdJv 4I8152RxAYAcbm0JH+0HFRVfv/PAWHOTP0ikzxWOLSuRKsRwe4fECG1NRV1I3L/9qnus H2ME9vx0MRGhxSU7RLwOnkTB5ohI2S19MgCq0j968Nwy30osSIQpDnXT0wMayf/grOQw VTYz6J7KgmiIZgaE78044lx/e3CBCT2nrLtufRlGMr2cFLPpOMp8WInoORZDEv/j9B0Q 2U/g== X-Gm-Message-State: AOAM530Sgn8sIgLEuQlc7HQZFKnhqQ0U8tSJIIexGZ3d1Lp7ZhzAdJO2 eoV6yL8VS4zWgeipReACVwjW51BcxlcsjzZ2BWkB6qFGaiEHewdz9mYzxjsF1IyVlM4hhJ/xn9v OWbFd32TP6AWdjkOyC/bGsmF50HzN X-Received: by 2002:a37:9301:: with SMTP id v1mr20962168qkd.419.1607291267446; Sun, 06 Dec 2020 13:47:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTSYUz8GprH7ZZQl7rfRTzOkUrvIm8134juk0lMfV/+12SIrmCKNfTzdhZMT6UYl2b500iiQ== X-Received: by 2002:a37:9301:: with SMTP id v1mr20962158qkd.419.1607291267253; Sun, 06 Dec 2020 13:47:47 -0800 (PST) Received: from localhost (ip98-179-76-75.ph.ph.cox.net. [98.179.76.75]) by smtp.gmail.com with ESMTPSA id o5sm565190qti.47.2020.12.06.13.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2020 13:47:46 -0800 (PST) References: <20201205014340.148235-1-jsnitsel@redhat.com> <20201205014340.148235-3-jsnitsel@redhat.com> <875z5e99ez.fsf@nanos.tec.linutronix.de> User-agent: mu4e 1.4.10; emacs 27.1 From: Jerry Snitselaar To: Thomas Gleixner In-reply-to: <875z5e99ez.fsf@nanos.tec.linutronix.de> Date: Sun, 06 Dec 2020 14:47:45 -0700 Message-ID: <87im9ehaim.fsf@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnitsel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: Re: [Intel-gfx] [PATCH v3 2/4] drm/i915/pmu: Use kstat_irqs to get interrupt count X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , David Airlie , Matthew Garrett , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, James Bottomley , Jason Gunthorpe , Jarkko Sakkinen , dri-devel@lists.freedesktop.org, linux-integrity@vger.kernel.org, Peter Huewe Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Thomas Gleixner @ 2020-12-06 09:38 MST: > 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 I don't know the history behind this bit. I stumbled across it in cscope when looking for places using kstat_irqs. _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24C7EC433FE for ; Sun, 6 Dec 2020 21:49:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E821022581 for ; Sun, 6 Dec 2020 21:49:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725977AbgLFVtQ (ORCPT ); Sun, 6 Dec 2020 16:49:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:33484 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727375AbgLFVtQ (ORCPT ); Sun, 6 Dec 2020 16:49:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607291269; 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=OTK3a2EpgqcMFsmrPHPH78wqX4JkIQW5zqkRG3GIknw=; b=Hj0gyByvgDu0Rq1YE5neEAyLLyFJ9SXYRtEusp6RezfuEcypIUlm/pX/rYommhUVMYC7Yp +1g3x5Qxf8Srx7/o4IN8BAO7H8kndoatyrx7Wx4RIRqnfGJQpII0441YlDtdBmhoIyzog9 HT9mEOqAgK5OQy6rhseB94qg75+UgYA= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-394-ubgBTMetMxSKOG4hveI7Qg-1; Sun, 06 Dec 2020 16:47:47 -0500 X-MC-Unique: ubgBTMetMxSKOG4hveI7Qg-1 Received: by mail-qk1-f200.google.com with SMTP id t127so5793690qkf.0 for ; Sun, 06 Dec 2020 13:47:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=OTK3a2EpgqcMFsmrPHPH78wqX4JkIQW5zqkRG3GIknw=; b=PHSP80RYYg506WYSGFKG0D5rMsHlNwf0gN/EYl6+tKKqq/ZEU1v4VVu73r05bpi31D 2juIVjSy7+FgAVW+eLfuZ/dn5k2H0aOff9tAOlGmcPfow81JgG1VHMg6apnDPUii5sut tLCKdKi93TcbMZXgMddhoVEfYiYt3+JUw8zDlNhuroyo53recjLYQW8nWLnqhO/97qva iUwV6nSXQ9AZA+6S0KbbgzaamT/gK10QyJgrBKj/1slgLQiOeXjyT7wNzIkxNTi7bmyW gNUQJ9iUXiThoJrwjVAXqqb3P1fpdwO7Ul3CXUTb6Hl5fAR2X3PI4YaHtdwDO0P6lFDk jCbA== X-Gm-Message-State: AOAM533E/sqwP8xFX4pcrIqmb1BdXD1F5zL6Ch3LXJYcwCAp1jZmcGfQ tCb/Ps1WDIw3QmE86T9ATJ1w1Cwa49SjqPDBWhU6KC+2NeMZMnSd8Ofcg9gXm8IP44mvNtku2QW Hopx57EXyIXdcFQv5NYUtz/3Q1Ldp X-Received: by 2002:a37:9301:: with SMTP id v1mr20962176qkd.419.1607291267447; Sun, 06 Dec 2020 13:47:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTSYUz8GprH7ZZQl7rfRTzOkUrvIm8134juk0lMfV/+12SIrmCKNfTzdhZMT6UYl2b500iiQ== X-Received: by 2002:a37:9301:: with SMTP id v1mr20962158qkd.419.1607291267253; Sun, 06 Dec 2020 13:47:47 -0800 (PST) Received: from localhost (ip98-179-76-75.ph.ph.cox.net. [98.179.76.75]) by smtp.gmail.com with ESMTPSA id o5sm565190qti.47.2020.12.06.13.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2020 13:47:46 -0800 (PST) References: <20201205014340.148235-1-jsnitsel@redhat.com> <20201205014340.148235-3-jsnitsel@redhat.com> <875z5e99ez.fsf@nanos.tec.linutronix.de> User-agent: mu4e 1.4.10; emacs 27.1 From: Jerry Snitselaar To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, 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: <875z5e99ez.fsf@nanos.tec.linutronix.de> Date: Sun, 06 Dec 2020 14:47:45 -0700 Message-ID: <87im9ehaim.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org Thomas Gleixner @ 2020-12-06 09:38 MST: > 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 I don't know the history behind this bit. I stumbled across it in cscope when looking for places using kstat_irqs. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 746CCC433FE for ; Sun, 6 Dec 2020 21:47:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1144F20857 for ; Sun, 6 Dec 2020 21:47:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1144F20857 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 69BD289D4B; Sun, 6 Dec 2020 21:47:54 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8770189D6C for ; Sun, 6 Dec 2020 21:47:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607291271; 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=OTK3a2EpgqcMFsmrPHPH78wqX4JkIQW5zqkRG3GIknw=; b=FlZ0wNS/ycKBLEokaQYLOlmCnB3shNHP4xpWZ5n7P+reeoT7MAjiK/axVVJT6hQFcxO1RB E2nFQGH4Ee0ftXq+xeVSB2haUpLTcmgHBlwn9upx6ty5os1Qp3R/WKJdYEDswi+40BD/VP uB32SfucfJlwtyKJBborXBm46+o1wcg= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-398-RM0_1cf_OuSIh5x7GYK4Xg-1; Sun, 06 Dec 2020 16:47:47 -0500 X-MC-Unique: RM0_1cf_OuSIh5x7GYK4Xg-1 Received: by mail-qk1-f199.google.com with SMTP id q25so10703097qkm.17 for ; Sun, 06 Dec 2020 13:47:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=OTK3a2EpgqcMFsmrPHPH78wqX4JkIQW5zqkRG3GIknw=; b=UdgRedRyV7NrCfyG6D+5U6p/kJ7vvSmg8fhE5LGNrAEq95dQr3T8tzYt89ZG3KjtJb lpU4sb0pnLA948lJn73dWbgEhcr6OOagHWYyAJPCYbtCGSWqv2s32TLLeDooa3YhPskY wbq8nh1yA6uv0oWNRX0Pkn35ubsaFk+u23n9ogfrGB3+5NOAKmyJe2S6WLBryMsD0/do 9Gatpd/n8xaBnBID4rAuU/JdYEGQ21+0U/bNyEzgtxM/X8W3k6qn0NTWWp3NVvAb1LcY 81qlnkNCvM2Vie0PlPoUka1cffVuuCZNywUY5mZo0RZAlIG8Y6KDQaCTfg6mh4Gq2URS 88GA== X-Gm-Message-State: AOAM530a9nnFPEKbbST0UtpvSbWUnPaB6cN4pu4uPSeQjPDSLhvEYueo Mht5RuBvOfm5tg63O6pkd71sytx9JwUCPKyZ0JyLjPHgsgOI4saBx1HjZZKnAgX9W9PJ7qJWnON 0woJH5bXLxl01txrtbrJ0yxDlWNoh X-Received: by 2002:a37:9301:: with SMTP id v1mr20962174qkd.419.1607291267447; Sun, 06 Dec 2020 13:47:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTSYUz8GprH7ZZQl7rfRTzOkUrvIm8134juk0lMfV/+12SIrmCKNfTzdhZMT6UYl2b500iiQ== X-Received: by 2002:a37:9301:: with SMTP id v1mr20962158qkd.419.1607291267253; Sun, 06 Dec 2020 13:47:47 -0800 (PST) Received: from localhost (ip98-179-76-75.ph.ph.cox.net. [98.179.76.75]) by smtp.gmail.com with ESMTPSA id o5sm565190qti.47.2020.12.06.13.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2020 13:47:46 -0800 (PST) References: <20201205014340.148235-1-jsnitsel@redhat.com> <20201205014340.148235-3-jsnitsel@redhat.com> <875z5e99ez.fsf@nanos.tec.linutronix.de> User-agent: mu4e 1.4.10; emacs 27.1 From: Jerry Snitselaar To: Thomas Gleixner Subject: Re: [PATCH v3 2/4] drm/i915/pmu: Use kstat_irqs to get interrupt count In-reply-to: <875z5e99ez.fsf@nanos.tec.linutronix.de> Date: Sun, 06 Dec 2020 14:47:45 -0700 Message-ID: <87im9ehaim.fsf@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnitsel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Hans de Goede , David Airlie , Matthew Garrett , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, James Bottomley , Jason Gunthorpe , Jarkko Sakkinen , dri-devel@lists.freedesktop.org, Rodrigo Vivi , linux-integrity@vger.kernel.org, Peter Huewe Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Thomas Gleixner @ 2020-12-06 09:38 MST: > 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 I don't know the history behind this bit. I stumbled across it in cscope when looking for places using kstat_irqs. _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel