From patchwork Tue Oct 31 02:28:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 117513 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3312187qgn; Mon, 30 Oct 2017 19:30:30 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RnCERvF9bqsIxAsaXm4/1+k2THqLjiww0nQg41JkPSOQpOuV7tddpo6WYCK3nRA0LYeV5Z X-Received: by 10.99.121.9 with SMTP id u9mr401025pgc.37.1509417030815; Mon, 30 Oct 2017 19:30:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509417030; cv=none; d=google.com; s=arc-20160816; b=PGzz33KwJyRPfdK85kGJsglYcyteaa3AQG7Mm6WpQ/+PQmTaTJ6lUaiD5CET0+ija9 wG/40XgGXnxL/y83MLAKYZVF3UO/NECbnONFujm5sel1K9yeWQ32b+p3Zq7B6nXUZSkL h7SUsJfSuBDDBOX0dP8/loTBs6AWy15OKZHHBy1PcaS3iIq2TZt02kPdXtHR7SZHDpsL KZGGYaHqd2P0CfY3FGBxFmg4yPYRHZsLq09jSJQnLd2ZRwJbWS1AVfZRgHYof+A2YqOi PMeg8VTEv/cR2tzc0x7z+Ag2ejO0+G5HU7RDukHfMsa/+DuB0OnYxw6UstDO2ZmTq6dI 4YtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=wYkYVaGxRsfQBUL3HoYVLs641gDkcPoY99rb4KzHUTg=; b=c/EmtBcT8C2qC0zsd3MW8KiibP7MhFM0FHJ1nQQCNbLhxTkd8QQ7Np/Szwe8f22b2l B31p2MJcVJfXKi8eXIVjB8+c7yxTxQnqbTDFO4mYBfYu8n0GM+ycD86Mbth6rTGo6x4B /VOiWVNg0rpjPch6xRWYGt9CmhFc7zvPYsoHOoBVaOe+dncZxaoOq3fOimF6ZKdP+Gc+ QsZPSJMdvew3n9wh1C+bPP4izJjiBPvYUOsGjzSWKVnB7PoggnrmTVHiPgTbh4jZzGF0 1Ox/9oKjSMj+M6AIT7G7J2kLDtjN7dK9K6fmZlsGse3ByaH1/VkrdoDNq2UY4qcv/Upy 3ebw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=PmnqD7Od; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 190si323843pgi.574.2017.10.30.19.30.30; Mon, 30 Oct 2017 19:30:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=PmnqD7Od; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752943AbdJaCa2 (ORCPT + 27 others); Mon, 30 Oct 2017 22:30:28 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:64374 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751837AbdJaCa1 (ORCPT ); Mon, 30 Oct 2017 22:30:27 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id v9V2T5rB006527; Tue, 31 Oct 2017 11:29:05 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com v9V2T5rB006527 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1509416945; bh=wYkYVaGxRsfQBUL3HoYVLs641gDkcPoY99rb4KzHUTg=; h=From:To:Cc:Subject:Date:From; b=PmnqD7Od1mKs7IOLbDDhuv5allv/iYTYpAVwVOod7kld9foh54DtQdFDEMBN0OWi/ XoXLdVHW9eKJD+0/+I5SLKXFT31na4pdK/l8BDejxkbNy8qQzLeXmLPeDE55LHnmG+ E06vGduSlRbrLo0h6lzTZkDogKFRinCrkTYxtEx5sRyI4SeUbNCEdEy8WVe7yLzE9X TrP35PUu8l23/Dz8VNlP0tkHOo8UcbNKhnJ56bxMD9eukpHvkJuwncn/4QG+zKkIPF qEypwnZNbFdsBgoMEtnK8jzo2qRPn8EMC0+y+bEfIzkkBlpTB2RqFwwlwNE2kxXE5c p+ZD/B97+0gFw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Thomas Gleixner Cc: Peter Zijlstra , Ingo Molnar , "Paul E . McKenney" , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH] genirq: add mutex and rcu locking to irq_desc_tree Date: Tue, 31 Oct 2017 11:28:48 +0900 Message-Id: <1509416928-7450-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a mutex to prevent concurrency on the updater side of the irq_desc radix tree. Add rcu_read_lock/unlock to the reader side so that lifetimes of leaf pointers of the radix tree are correctly managed. Signed-off-by: Masahiro Yamada --- kernel/irq/irqdesc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 82afb7e..928c896 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -312,21 +313,32 @@ static void irq_sysfs_add(int irq, struct irq_desc *desc) {} #endif /* CONFIG_SYSFS */ static RADIX_TREE(irq_desc_tree, GFP_KERNEL); +static DEFINE_MUTEX(irq_desc_tree_mutex); static void irq_insert_desc(unsigned int irq, struct irq_desc *desc) { + mutex_lock(&irq_desc_tree_mutex); radix_tree_insert(&irq_desc_tree, irq, desc); + mutex_unlock(&irq_desc_tree_mutex); } struct irq_desc *irq_to_desc(unsigned int irq) { - return radix_tree_lookup(&irq_desc_tree, irq); + struct irq_desc *desc; + + rcu_read_lock(); + desc = radix_tree_lookup(&irq_desc_tree, irq); + rcu_read_unlock(); + + return desc; } EXPORT_SYMBOL(irq_to_desc); static void delete_irq_desc(unsigned int irq) { + mutex_lock(&irq_desc_tree_mutex); radix_tree_delete(&irq_desc_tree, irq); + mutex_unlock(&irq_desc_tree_mutex); } #ifdef CONFIG_SMP