Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1852292pxb; Mon, 13 Sep 2021 06:57:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmeTJ8Gozaqhc3IUPinZwYMUH5u3HADkIWjbVRZHRalNdKys1AnOooTbPpmW16vl558I0G X-Received: by 2002:a05:6402:1d25:: with SMTP id dh5mr13192564edb.91.1631541464196; Mon, 13 Sep 2021 06:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631541464; cv=none; d=google.com; s=arc-20160816; b=GKRTS5MvmYJbbIyjrJspXEiify+ID9kOY/UpM93DLh/ZBvIozIQcrQX+jydnMxGFEj zC09mYvcTW0I5vdELV7iDjttBm4qQz1SpR1/RRIT+M2I4aLH/b2V9D+YHHo0lciCBne6 thPR8ubO85RLW7nt6cP8BJyyCHyUZXpzlyBeLYMN1qU7JYBU8/6Jqja0lYHrvzu1jlzR 41+EOQaLNw1wllHN3OFLuCBmagatuuvU3HPis7OX6VkVuYGI/SweJiBy8Lj1PwCrpkx9 l1UOAL4WRDXrmh0YaWL7xTgRMi68xDQPEmJ41QcMkVlp/9xnkL6kd68kyuue+N0vxPp0 sz+Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NDa7uDPPVQef225dOE9AHx+PGJbHX+jS9IJqnzZh/p4=; b=SgSCTXupK0rq/SKs1MhSh6QkQZzJEpU/h+dkI9qE1x4chQ9XV3hgC0Y3uvqgpfdfpd pesdj4f8O2HEoOcXEJ/r76wBZI0Zp0EkPobfvyiVTeq673H0sPbnjSMgiN198oPfit52 5sYv0cvYoncsEVvjF8RRc7Yuldb0TfNUaZlFNdTwjFazT57MNOWmVFMpyzaaxLwwQE6m PT+rH3kNoG3yuqiE76rFjsCRRbpL6spYKNXuxkQFrLjRv0E21jAMzMOyO+JuZ5S7d9CB eAqBqT6iOoJuRZL0+ZASEEpi1RDMXBwoNke4WxQ4XL7VQGeJ8dHtndX32h3fPIjmaYZN Vyqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K0XGEVMs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t22si7446215ejt.594.2021.09.13.06.57.19; Mon, 13 Sep 2021 06:57:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K0XGEVMs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243528AbhIMN4W (ORCPT + 99 others); Mon, 13 Sep 2021 09:56:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:40390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243611AbhIMNxh (ORCPT ); Mon, 13 Sep 2021 09:53:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6EA0361994; Mon, 13 Sep 2021 13:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540091; bh=eDgv26IYjTek4tHtjF1IaMYKXOB7/58/E6cQPlvcs4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K0XGEVMs1uU+ewzlBXf71zwpX2CV9zuf/e3Ji/D7Uia26cWpiyHD+TFw7iEAT19fz Yg0NDfq84EB2soWGMEVu+H23j8buD+nXI1kQBwwz+czCzOsQze4SngFYkS+NFXCA8Z Q8JlCnzu2+Oz7oQgtSxVksEiskE6jDeBLS1rsuIw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Valentin Schneider , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 5.13 047/300] sched/debug: Dont update sched_domain debug directories before sched_debug_init() Date: Mon, 13 Sep 2021 15:11:48 +0200 Message-Id: <20210913131110.929879978@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Valentin Schneider [ Upstream commit 459b09b5a3254008b63382bf41a9b36d0b590f57 ] Since CPU capacity asymmetry can stem purely from maximum frequency differences (e.g. Pixel 1), a rebuild of the scheduler topology can be issued upon loading cpufreq, see: arch_topology.c::init_cpu_capacity_callback() Turns out that if this rebuild happens *before* sched_debug_init() is run (which is a late initcall), we end up messing up the sched_domain debug directory: passing a NULL parent to debugfs_create_dir() ends up creating the directory at the debugfs root, which in this case creates /sys/kernel/debug/domains (instead of /sys/kernel/debug/sched/domains). This currently doesn't happen on asymmetric systems which use cpufreq-scpi or cpufreq-dt drivers, as those are loaded via deferred_probe_initcall() (it is also a late initcall, but appears to be ordered *after* sched_debug_init()). Ionela has been working on detecting maximum frequency asymmetry via ACPI, and that actually happens via a *device* initcall, thus before sched_debug_init(), and causes the aforementionned debugfs mayhem. One option would be to punt sched_debug_init() down to fs_initcall_sync(). Preventing update_sched_domain_debugfs() from running before sched_debug_init() appears to be the safer option. Fixes: 3b87f136f8fc ("sched,debug: Convert sysctl sched_domains to debugfs") Signed-off-by: Valentin Schneider Signed-off-by: Peter Zijlstra (Intel) Link: http://lore.kernel.org/r/20210514095339.12979-1-ionela.voinescu@arm.com Signed-off-by: Sasha Levin --- kernel/sched/debug.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index c5aacbd492a1..f8c94bebd17d 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -388,6 +388,13 @@ void update_sched_domain_debugfs(void) { int cpu, i; + /* + * This can unfortunately be invoked before sched_debug_init() creates + * the debug directory. Don't touch sd_sysctl_cpus until then. + */ + if (!debugfs_sched) + return; + if (!cpumask_available(sd_sysctl_cpus)) { if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL)) return; -- 2.30.2