From patchwork Tue Nov 24 06:17:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 11927251 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 B15FBC56201 for ; Tue, 24 Nov 2020 06:19:26 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 2857A20678 for ; Tue, 24 Nov 2020 06:19:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gTtJBAAO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2857A20678 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NZ06MvXvpFD0RgkGWh4BT44Xxs46Dk6x+TayrMkx05o=; b=gTtJBAAOzLVp/uhEqOfXUXTsIh QXwUKu7IDLum89IrCFl0zDZRhSnR1FA3qE6HpUR8rCzPf+uGQoo0PrK1Bx9Q0PClT5n1dhBeKd8iV NDsbRGSswBJw+WzmEX75mfaYHdYfKrvRLVPdGIqYJ1YemPsgwT08YNEW0esArB6HLUSXNROIFB8EZ Lpm9BxgxaZfqHREF5LIvJbMgN1Sux/lE1WQxuJFp49avykZJvQIyCQgTpfJaDagFB0xXq0x9+1dl6 doFTOLavcMM7CUcLEhl1FGsKpy3WGxXKrg0+C0fuHlosAx6jCMR6cIS/9xcD6momnhp5cF6ilp4MC 3/55+yJA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khReW-0007JG-W4; Tue, 24 Nov 2020 06:18:13 +0000 Received: from ozlabs.ru ([107.174.27.60]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khReN-0007Gp-28 for linux-arm-kernel@lists.infradead.org; Tue, 24 Nov 2020 06:18:03 +0000 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 894A2AE8024F; Tue, 24 Nov 2020 01:17:57 -0500 (EST) From: Alexey Kardashevskiy To: linux-kernel@vger.kernel.org Subject: [PATCH kernel v4 4/8] genirq: Free IRQ descriptor via embedded kobject Date: Tue, 24 Nov 2020 17:17:16 +1100 Message-Id: <20201124061720.86766-5-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201124061720.86766-1-aik@ozlabs.ru> References: <20201124061720.86766-1-aik@ozlabs.ru> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201124_011803_203647_2DB83F96 X-CRM114-Status: GOOD ( 14.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Marc Zyngier , x86@kernel.org, linux-gpio@vger.kernel.org, Oliver O'Halloran , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Frederic Barrat , Thomas Gleixner , =?utf-8?q?Michal_Such=C3=A1nek?= , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org At the moment the IRQ descriptor is freed via the free_desc() helper. We want to add reference counting to IRQ descriptors and there is already kobj embedded into irq_desc which we want to reuse. This shuffles free_desc()/etc to make it simply call kobject_put() and moves all the cleanup into the kobject_release hook. As a bonus, we do not need irq_sysfs_del() as kobj removes itself from sysfs if it knows that it was added. This should cause no behavioral change. Signed-off-by: Alexey Kardashevskiy --- kernel/irq/irqdesc.c | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 1a7723604399..75374b7944b5 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -295,18 +295,6 @@ static void irq_sysfs_add(int irq, struct irq_desc *desc) } } -static void irq_sysfs_del(struct irq_desc *desc) -{ - /* - * If irq_sysfs_init() has not yet been invoked (early boot), then - * irq_kobj_base is NULL and the descriptor was never added. - * kobject_del() complains about a object with no parent, so make - * it conditional. - */ - if (irq_kobj_base) - kobject_del(&desc->kobj); -} - static int __init irq_sysfs_init(void) { struct irq_desc *desc; @@ -337,7 +325,6 @@ static struct kobj_type irq_kobj_type = { }; static void irq_sysfs_add(int irq, struct irq_desc *desc) {} -static void irq_sysfs_del(struct irq_desc *desc) {} #endif /* CONFIG_SYSFS */ @@ -419,39 +406,34 @@ static struct irq_desc *alloc_desc(int irq, int node, unsigned int flags, return NULL; } -static void irq_kobj_release(struct kobject *kobj) -{ - struct irq_desc *desc = container_of(kobj, struct irq_desc, kobj); - - free_masks(desc); - free_percpu(desc->kstat_irqs); - kfree(desc); -} - static void delayed_free_desc(struct rcu_head *rhp) { struct irq_desc *desc = container_of(rhp, struct irq_desc, rcu); + free_masks(desc); + free_percpu(desc->kstat_irqs); + kfree(desc); +} + +static void free_desc(unsigned int irq) +{ + struct irq_desc *desc = irq_to_desc(irq); + kobject_put(&desc->kobj); } -static void free_desc(unsigned int irq) +static void irq_kobj_release(struct kobject *kobj) { - struct irq_desc *desc = irq_to_desc(irq); + struct irq_desc *desc = container_of(kobj, struct irq_desc, kobj); + unsigned int irq = desc->irq_data.irq; irq_remove_debugfs_entry(desc); unregister_irq_proc(irq, desc); /* - * sparse_irq_lock protects also show_interrupts() and - * kstat_irq_usr(). Once we deleted the descriptor from the - * sparse tree we can free it. Access in proc will fail to - * lookup the descriptor. - * * The sysfs entry must be serialized against a concurrent * irq_sysfs_init() as well. */ - irq_sysfs_del(desc); delete_irq_desc(irq); /*