Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp802629pxb; Fri, 22 Apr 2022 11:27:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1gWuhB224yCrY6JnE1enEzJ8kWTUyTYvBv/Ac4By6lEQaW8DmZrXfvFTn766/lG3qpMWF X-Received: by 2002:a17:902:7684:b0:156:25b3:ef6b with SMTP id m4-20020a170902768400b0015625b3ef6bmr5602336pll.39.1650652042882; Fri, 22 Apr 2022 11:27:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650652042; cv=none; d=google.com; s=arc-20160816; b=norUE7Loyul1BPOiGq1ib0U4Yk26HH4bRVzxe1G1jHRBx4yfLo3f1ZEh6j0kwFhPkv oSsQE7OHDQwAKMG3agUWc9XrKrF2nTV6YtHiQ7OmWrAF67bwUZscEjhgEV03cebHVMex +R0+Pz1bzMVMjr9wVpMkmjeb62b41fGSfnBxZg0QpCFyBpxxFscpD1pW/TMgFQawCufe qXJacefH7/kckKKzkY5g6o8la/Nhs6X6h+PpteYob8VF7/BhaJ/LpEa2OhdFAqixlVvQ pWt0u//8txT64nOFWqj2p8wrGKCE7VnwQFjZ34N7QWKQhCYZUdcZ3Fw0WbAox3w3L3eY xQIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2khFeLeVUO5ld1xI1BAqlcBSQpfcvbdSYE3+epMyuqI=; b=AaSkC7g2kYdD4HeKktsKeLCsWljoMd4/b+pvZ9P2GQ8VvaMwPqlX8x0TJwLxOkBWJK LLWHBoIzMsCzisEiePgG/WkfS0hOgeGCJ9hetPcAMjCEqRm7sJVWwR2vYce9r94dvYYD +a3Sf4XY+qfYh2V89NOf64ZGzjpRYyAlfj3b0e9s0YwGeb2fjKpk5ZYdD9DibWjg2pET o9tH7hk0LeJ+VH/ThK7fNb3wEWN/x7rgpbTdkwv6UthWwpzlcomapE45bZ21/szDiN7J eZI76+6H4neJmXdfqgzKoMxOugvTThbOfI447TU+3Vu8k2XHhbK/XH1s7Eetl1EKOfub URlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aeWdipoC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bh10-20020a056a02020a00b003aae4f1097asi586898pgb.559.2022.04.22.11.27.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 11:27:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aeWdipoC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8DF8DF4B1C; Fri, 22 Apr 2022 10:55:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379340AbiDTOJB (ORCPT + 99 others); Wed, 20 Apr 2022 10:09:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379335AbiDTOIy (ORCPT ); Wed, 20 Apr 2022 10:08:54 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 172764349B for ; Wed, 20 Apr 2022 07:06:09 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id p3so685954pfw.0 for ; Wed, 20 Apr 2022 07:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2khFeLeVUO5ld1xI1BAqlcBSQpfcvbdSYE3+epMyuqI=; b=aeWdipoCVBqQ0XwlZV5CrcAVoHIe3L5+uvMQKpqsl5P76/cMWR8jB8f1opjELbHStN 9M4Q29RMQEJntWJS1g9GXV4ByQLPo2V/YSsgRgfNFcok6LHwU1h+EiutqDIMkutN2Ap1 L8eJUZqH6evHozuVd7xD8iZJQzWfKAg5RQM4uV1qAowMz6D5W5jOXspcZuUtnIGLDmF9 +PvzXfhjpOjx1kJ/3DtQwr32MbTzr6P/ZPDJE3v+kN1mep0Y3xXLNw4K+VIW+Lhmz9Vc HsHSLII9Z+oRbYV2vcj8+mETp6NnfMUyH02E4teMuvm754fUVCegrOH1PxSC21FkDoxi KV0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2khFeLeVUO5ld1xI1BAqlcBSQpfcvbdSYE3+epMyuqI=; b=lIblwm/EwRVXrGVPdefW31BD+CEUOzlTLnKFFCzJxynafSEUopts2RuQ5C16zOu7Oq UaRMyvzh1pSL3F4Upi3s8jPfrnZDK+YTOkGL/U5P2ZoeywdaYMj2/8Vaqz1y0etZIyu7 TH8lUmhinxEPSz2KjX2g3IORZyIJRUi2XsQzfw1jSCG24R9FGTQoCWqOkQKNLGeuCmwR LuL6vW6NWVPuIoGoInFRJMyndK1/cbF1PRwC8pTNpU4lbz9OsPNdUNc94CyY72s+u/fk xatAEB+kQrjH9y5agO8jMOCzW3QDiLjugj81hjImVC3QTnXvkrPHe0coQVm+tericFfx 87jA== X-Gm-Message-State: AOAM5330PlFEbLQqi5iFUrXJlpqudsYwZRRzt9uB+TxDGCz8u1GMKIi5 VFeXN+zGtOP4vq47r4CReHnUjO69iQ== X-Received: by 2002:a63:4c4b:0:b0:3aa:4af8:9ab8 with SMTP id m11-20020a634c4b000000b003aa4af89ab8mr5816697pgl.430.1650463568427; Wed, 20 Apr 2022 07:06:08 -0700 (PDT) Received: from piliu.users.ipa.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id br10-20020a056a00440a00b0050a777cd10csm10959178pfb.91.2022.04.20.07.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 07:06:07 -0700 (PDT) From: Pingfan Liu To: linux-kernel@vger.kernel.org Cc: Pingfan Liu , Thomas Gleixner , Valentin Schneider , Peter Zijlstra , Frederic Weisbecker , Baokun Li , Mark Rutland , Steven Price , "Jason A. Donenfeld" , Yuan ZhaoXiong , YueHaibing , Randy Dunlap Subject: [PATCH 7/9] irq: remove needless lock in takedown_cpu() Date: Wed, 20 Apr 2022 22:05:19 +0800 Message-Id: <20220420140521.45361-8-kernelfans@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220420140521.45361-1-kernelfans@gmail.com> References: <20220420140521.45361-1-kernelfans@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Any allocation or release of irq_desc should fall into the interface of __irq_alloc_descs() or irq_free_descs(). And both of them hold the mutex sparse_irq_lock. This preemptability contradicts the preempt-disabled context when dispatching fn in cpu_stopper_thread(). So allocation or free of irq_desc can not be demanded in cpu_stopper_thread(). On the other hand, for the safety of access to irq_desc, rcu still keeps watching the dying cpu until the last minute rcu_report_dead(), so each cpu_stop_fn_t can safely access irq_desc. As a result, in takedown_cpu() irq_lock_sparse()/irq_unlock_sparse() can be safely removed. Signed-off-by: Pingfan Liu Cc: Thomas Gleixner Cc: Valentin Schneider Cc: Peter Zijlstra Cc: Frederic Weisbecker Cc: Baokun Li Cc: Mark Rutland Cc: Steven Price Cc: "Jason A. Donenfeld" Cc: Yuan ZhaoXiong Cc: YueHaibing Cc: Randy Dunlap To: linux-kernel@vger.kernel.org --- kernel/cpu.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index d0a9aa0b42e8..94a6b512c26d 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1033,18 +1033,16 @@ static int takedown_cpu(unsigned int cpu) kthread_park(st->thread); /* - * Prevent irq alloc/free while the dying cpu reorganizes the - * interrupt affinities. + * RCU keeps watching 'cpu' until do_idle()->rcu_report_dead(). + * And cpu_stopper's fn is dispatched with preemption disabled. + * So it can not occur to release a irq_desc. */ - irq_lock_sparse(); /* * So now all preempt/rcu users must observe !cpu_active(). */ err = stop_machine_cpuslocked(take_cpu_down, NULL, cpumask_of(cpu)); if (err) { - /* CPU refused to die */ - irq_unlock_sparse(); /* Unpark the hotplug thread so we can rollback there */ kthread_unpark(st->thread); return err; @@ -1061,9 +1059,6 @@ static int takedown_cpu(unsigned int cpu) wait_for_ap_thread(st, false); BUG_ON(st->state != CPUHP_AP_IDLE_DEAD); - /* Interrupts are moved away from the dying cpu, reenable alloc/free */ - irq_unlock_sparse(); - hotplug_cpu__broadcast_tick_pull(cpu); /* This actually kills the CPU. */ __cpu_die(cpu); -- 2.31.1