From patchwork Mon Aug 22 02:15:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 12950124 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2D2A6C00140 for ; Mon, 22 Aug 2022 02:18:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2qJ9alaaJx84hFVnr5+fa+byGSX3LaQUp4IE7SAB5Mg=; b=OYrehm046qrLZn jZRzQBEHBKglHOPRLt5abau/CEQVbchEw7Zv0E+2Si1yzNuTxei+zdic8ANys9pDcQL+sboWembLG Uq/ak610BurgC6uM8Rh4ss5hQQAzJrdlwEYJQOSH9oHaX5Xm6mhiVsbyzryT37Yzd56SkgmFX0Qcu Uw5aRT4G5+f4QnG/voB/4T5OO8gtFDdysBBF9YrBc6ReiWsN+o6KES/4GmWBv2TaZVNJlYNARGsRZ RjOKz5NEiDRO+KAV1QRGLF4TDXrpRTQMiVY4l/LqcRCtLkAaqmFZ4SsRJ3+IAgXt1DnTeK6kL9zOJ vTUsiID9W0FhfhsgtfsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPwzt-003lvv-74; Mon, 22 Aug 2022 02:17:01 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPwz4-003lCB-Lc for linux-arm-kernel@lists.infradead.org; Mon, 22 Aug 2022 02:16:12 +0000 Received: by mail-pf1-x432.google.com with SMTP id p9so7942924pfq.13 for ; Sun, 21 Aug 2022 19:16:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=gsR63uXiD4J4dRjeMZsAaLt2fDvFcRZsnDNlGseIAjE=; b=Pk0rIhqwd8AcUkq5KmJe9mjrUF6uNVfJWfjWUkbfwuQIGmV+U3/UFgPVoh1gYGq+bd lbCSRPMb+1x0M86+ymqwzFqN8nb+l68wSITrsmEixSWhlHgDZLB/R0svIyy5MO54R6Ym PwVfSVkrB8SoRCQ7vzL1LQZzM9iHBwApzh6vrmeiZsltT6ynaL3sdrb1ZhJGPhmFyOD3 4s2db1YqPkPeaWJ6qcSkXxuYfgRl3Eokk297cD1GGHz/Q5l5MVSGxbVpp3c4meit/hP+ bSsrrIKUfzH3yc9hotWq9Z7duppQSn0jH3GGkXZbsN3yxozQbvoh5tqw/X+vXNhleLsl cX7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=gsR63uXiD4J4dRjeMZsAaLt2fDvFcRZsnDNlGseIAjE=; b=6IdXOaP48SoYfOCJuIsVEe+0W/8Wy2zUw/6Cy+RDHEfmboo9IPloAYrd2sgAoawwtS qjOEFPklNxlPbO2wds/EeFTUyORBwH3g+TvSY34xEuPtu7gqpo4OlC8i7SFkF39TPaun eSkBJ/Pi9VYWUkLSnCuRKqL8mfTHKzyfTJE/wTsWqc2sBR22ej67uxI+srNqqB2xS1wm hle/auSQuw6uNBoBnIVkf230+fIK2UYuPh3gZ/8YNe34pmI8Rf+8xIi3JlB1D+bjBjoD YCLZyr111ZsgiJTkEOsPylWZcLxmPUl1HgUEIwtHDF00zoZCVxteS8vs/AfBsDBbHMnp 9wWw== X-Gm-Message-State: ACgBeo2XucSFS7A908zwNIDMFlqTQHvq018Vi0ZtdCrMycALmjVzbwFh KoOAUREnR/tSbK7O66HNIU/KZFZ1Eg== X-Google-Smtp-Source: AA6agR796+xdB/mm2oEQUhLS61HVQaOmFzmcD/yNrFj1veXL2aZ9RxDMlPamwMMKooh9so1wCzMtIA== X-Received: by 2002:a63:4b62:0:b0:421:8c8b:163c with SMTP id k34-20020a634b62000000b004218c8b163cmr14624442pgl.182.1661134569229; Sun, 21 Aug 2022 19:16:09 -0700 (PDT) Received: from piliu.users.ipa.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id k3-20020aa79723000000b005321340753fsm7312139pfg.103.2022.08.21.19.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Aug 2022 19:16:08 -0700 (PDT) From: Pingfan Liu To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Pingfan Liu , Will Deacon , Mark Rutland Subject: [RFC 05/10] perf/arm-dsu: Make dsu_pmu_cpu_teardown() parallel Date: Mon, 22 Aug 2022 10:15:15 +0800 Message-Id: <20220822021520.6996-6-kernelfans@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220822021520.6996-1-kernelfans@gmail.com> References: <20220822021520.6996-1-kernelfans@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220821_191610_810584_6EDF4277 X-CRM114-Status: GOOD ( 13.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In the case of kexec quick reboot, dsu_pmu_cpu_teardown() confronts parallel and lock are needed to protect the contest on a dsu_pmu. Signed-off-by: Pingfan Liu Cc: Will Deacon Cc: Mark Rutland To: linux-arm-kernel@lists.infradead.org To: linux-kernel@vger.kernel.org --- drivers/perf/arm_dsu_pmu.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/perf/arm_dsu_pmu.c b/drivers/perf/arm_dsu_pmu.c index a36698a90d2f..aa9f4393ff0c 100644 --- a/drivers/perf/arm_dsu_pmu.c +++ b/drivers/perf/arm_dsu_pmu.c @@ -833,16 +833,23 @@ static int dsu_pmu_cpu_teardown(unsigned int cpu, struct hlist_node *node) struct dsu_pmu *dsu_pmu = hlist_entry_safe(node, struct dsu_pmu, cpuhp_node); - if (!cpumask_test_and_clear_cpu(cpu, &dsu_pmu->active_cpu)) + raw_spin_lock(&dsu_pmu->pmu_lock); + if (!cpumask_test_and_clear_cpu(cpu, &dsu_pmu->active_cpu)) { + raw_spin_unlock(&dsu_pmu->pmu_lock); return 0; + } dst = dsu_pmu_get_online_cpu_any_but(dsu_pmu, cpu); /* If there are no active CPUs in the DSU, leave IRQ disabled */ - if (dst >= nr_cpu_ids) + if (dst >= nr_cpu_ids) { + raw_spin_unlock(&dsu_pmu->pmu_lock); return 0; + } - perf_pmu_migrate_context(&dsu_pmu->pmu, cpu, dst); + /* dst should not be in dying mask. So after setting, blocking parallel */ dsu_pmu_set_active_cpu(dst, dsu_pmu); + raw_spin_unlock(&dsu_pmu->pmu_lock); + perf_pmu_migrate_context(&dsu_pmu->pmu, cpu, dst); return 0; } @@ -858,6 +865,7 @@ static int __init dsu_pmu_init(void) if (ret < 0) return ret; dsu_pmu_cpuhp_state = ret; + cpuhp_set_step_parallel(ret); return platform_driver_register(&dsu_pmu_driver); }