linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Kevin Hao <haokexin@gmail.com>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.10 02/93] cpufreq: schedutil: Use kobject release() method to free sugov_tunables
Date: Mon,  4 Oct 2021 14:52:00 +0200	[thread overview]
Message-ID: <20211004125034.665736576@linuxfoundation.org> (raw)
In-Reply-To: <20211004125034.579439135@linuxfoundation.org>

From: Kevin Hao <haokexin@gmail.com>

[ Upstream commit e5c6b312ce3cc97e90ea159446e6bfa06645364d ]

The struct sugov_tunables is protected by the kobject, so we can't free
it directly. Otherwise we would get a call trace like this:
  ODEBUG: free active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x30
  WARNING: CPU: 3 PID: 720 at lib/debugobjects.c:505 debug_print_object+0xb8/0x100
  Modules linked in:
  CPU: 3 PID: 720 Comm: a.sh Tainted: G        W         5.14.0-rc1-next-20210715-yocto-standard+ #507
  Hardware name: Marvell OcteonTX CN96XX board (DT)
  pstate: 40400009 (nZcv daif +PAN -UAO -TCO BTYPE=--)
  pc : debug_print_object+0xb8/0x100
  lr : debug_print_object+0xb8/0x100
  sp : ffff80001ecaf910
  x29: ffff80001ecaf910 x28: ffff00011b10b8d0 x27: ffff800011043d80
  x26: ffff00011a8f0000 x25: ffff800013cb3ff0 x24: 0000000000000000
  x23: ffff80001142aa68 x22: ffff800011043d80 x21: ffff00010de46f20
  x20: ffff800013c0c520 x19: ffff800011d8f5b0 x18: 0000000000000010
  x17: 6e6968207473696c x16: 5f72656d6974203a x15: 6570797420746365
  x14: 6a626f2029302065 x13: 303378302f307830 x12: 2b6e665f72656d69
  x11: ffff8000124b1560 x10: ffff800012331520 x9 : ffff8000100ca6b0
  x8 : 000000000017ffe8 x7 : c0000000fffeffff x6 : 0000000000000001
  x5 : ffff800011d8c000 x4 : ffff800011d8c740 x3 : 0000000000000000
  x2 : ffff0001108301c0 x1 : ab3c90eedf9c0f00 x0 : 0000000000000000
  Call trace:
   debug_print_object+0xb8/0x100
   __debug_check_no_obj_freed+0x1c0/0x230
   debug_check_no_obj_freed+0x20/0x88
   slab_free_freelist_hook+0x154/0x1c8
   kfree+0x114/0x5d0
   sugov_exit+0xbc/0xc0
   cpufreq_exit_governor+0x44/0x90
   cpufreq_set_policy+0x268/0x4a8
   store_scaling_governor+0xe0/0x128
   store+0xc0/0xf0
   sysfs_kf_write+0x54/0x80
   kernfs_fop_write_iter+0x128/0x1c0
   new_sync_write+0xf0/0x190
   vfs_write+0x2d4/0x478
   ksys_write+0x74/0x100
   __arm64_sys_write+0x24/0x30
   invoke_syscall.constprop.0+0x54/0xe0
   do_el0_svc+0x64/0x158
   el0_svc+0x2c/0xb0
   el0t_64_sync_handler+0xb0/0xb8
   el0t_64_sync+0x198/0x19c
  irq event stamp: 5518
  hardirqs last  enabled at (5517): [<ffff8000100cbd7c>] console_unlock+0x554/0x6c8
  hardirqs last disabled at (5518): [<ffff800010fc0638>] el1_dbg+0x28/0xa0
  softirqs last  enabled at (5504): [<ffff8000100106e0>] __do_softirq+0x4d0/0x6c0
  softirqs last disabled at (5483): [<ffff800010049548>] irq_exit+0x1b0/0x1b8

So split the original sugov_tunables_free() into two functions,
sugov_clear_global_tunables() is just used to clear the global_tunables
and the new sugov_tunables_free() is used as kobj_type::release to
release the sugov_tunables safely.

Fixes: 9bdcb44e391d ("cpufreq: schedutil: New governor based on scheduler utilization data")
Cc: 4.7+ <stable@vger.kernel.org> # 4.7+
Signed-off-by: Kevin Hao <haokexin@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/sched/cpufreq_schedutil.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 97d318b0cd0c..5e39da0ae086 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -610,9 +610,17 @@ static struct attribute *sugov_attrs[] = {
 };
 ATTRIBUTE_GROUPS(sugov);
 
+static void sugov_tunables_free(struct kobject *kobj)
+{
+	struct gov_attr_set *attr_set = container_of(kobj, struct gov_attr_set, kobj);
+
+	kfree(to_sugov_tunables(attr_set));
+}
+
 static struct kobj_type sugov_tunables_ktype = {
 	.default_groups = sugov_groups,
 	.sysfs_ops = &governor_sysfs_ops,
+	.release = &sugov_tunables_free,
 };
 
 /********************** cpufreq governor interface *********************/
@@ -712,12 +720,10 @@ static struct sugov_tunables *sugov_tunables_alloc(struct sugov_policy *sg_polic
 	return tunables;
 }
 
-static void sugov_tunables_free(struct sugov_tunables *tunables)
+static void sugov_clear_global_tunables(void)
 {
 	if (!have_governor_per_policy())
 		global_tunables = NULL;
-
-	kfree(tunables);
 }
 
 static int sugov_init(struct cpufreq_policy *policy)
@@ -780,7 +786,7 @@ out:
 fail:
 	kobject_put(&tunables->attr_set.kobj);
 	policy->governor_data = NULL;
-	sugov_tunables_free(tunables);
+	sugov_clear_global_tunables();
 
 stop_kthread:
 	sugov_kthread_stop(sg_policy);
@@ -807,7 +813,7 @@ static void sugov_exit(struct cpufreq_policy *policy)
 	count = gov_attr_set_put(&tunables->attr_set, &sg_policy->tunables_hook);
 	policy->governor_data = NULL;
 	if (!count)
-		sugov_tunables_free(tunables);
+		sugov_clear_global_tunables();
 
 	mutex_unlock(&global_tunables_lock);
 
-- 
2.33.0




  parent reply	other threads:[~2021-10-04 13:20 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04 12:51 [PATCH 5.10 00/93] 5.10.71-rc1 review Greg Kroah-Hartman
2021-10-04 12:51 ` [PATCH 5.10 01/93] tty: Fix out-of-bound vmalloc access in imageblit Greg Kroah-Hartman
2021-10-04 12:52 ` Greg Kroah-Hartman [this message]
2021-10-04 12:52 ` [PATCH 5.10 03/93] scsi: qla2xxx: Changes to support kdump kernel for NVMe BFS Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 04/93] cpufreq: schedutil: Destroy mutex before kobject_put() frees the memory Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 05/93] usb: cdns3: fix race condition before setting doorbell Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 06/93] ALSA: hda/realtek: Quirks to enable speaker output for Lenovo Legion 7i 15IMHG05, Yoga 7i 14ITL5/15ITL5, and 13s Gen2 laptops Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 07/93] ACPI: NFIT: Use fallback node id when numa info in NFIT table is incorrect Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 08/93] fs-verity: fix signed integer overflow with i_size near S64_MAX Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 09/93] hwmon: (tmp421) handle I2C errors Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 10/93] hwmon: (w83793) Fix NULL pointer dereference by removing unnecessary structure field Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 11/93] hwmon: (w83792d) " Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 12/93] hwmon: (w83791d) " Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 13/93] gpio: pca953x: do not ignore i2c errors Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 14/93] scsi: ufs: Fix illegal offset in UPIU event trace Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 15/93] mac80211: fix use-after-free in CCMP/GCMP RX Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 16/93] x86/kvmclock: Move this_cpu_pvti into kvmclock.h Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 17/93] KVM: x86: Fix stack-out-of-bounds memory access from ioapic_write_indirect() Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 18/93] KVM: x86: nSVM: dont copy virt_ext from vmcb12 Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 19/93] KVM: nVMX: Filter out all unsupported controls when eVMCS was activated Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 20/93] KVM: rseq: Update rseq when processing NOTIFY_RESUME on xfer to KVM guest Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 21/93] media: ir_toy: prevent device from hanging during transmit Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 22/93] RDMA/cma: Do not change route.addr.src_addr.ss_family Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 23/93] drm/amd/display: Pass PCI deviceid into DC Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 24/93] drm/amdgpu: correct initial cp_hqd_quantum for gfx9 Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 25/93] ipvs: check that ip_vs_conn_tab_bits is between 8 and 20 Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 26/93] bpf: Handle return value of BPF_PROG_TYPE_STRUCT_OPS prog Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 27/93] IB/cma: Do not send IGMP leaves for sendonly Multicast groups Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 28/93] RDMA/cma: Fix listener leak in rdma_cma_listen_on_all() failure Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 29/93] bpf, mips: Validate conditional branch offsets Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 30/93] hwmon: (mlxreg-fan) Return non-zero value when fan current state is enforced from sysfs Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 31/93] mac80211: Fix ieee80211_amsdu_aggregate frag_tail bug Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 32/93] mac80211: limit injected vht mcs/nss in ieee80211_parse_tx_radiotap Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 33/93] mac80211: mesh: fix potentially unaligned access Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 34/93] mac80211-hwsim: fix late beacon hrtimer handling Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 35/93] sctp: break out if skb_header_pointer returns NULL in sctp_rcv_ootb Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 36/93] mptcp: dont return sockets in foreign netns Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 37/93] hwmon: (tmp421) report /PVLD condition as fault Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 38/93] hwmon: (tmp421) fix rounding for negative values Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 39/93] net: enetc: fix the incorrect clearing of IF_MODE bits Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 40/93] net: ipv4: Fix rtnexthop len when RTA_FLOW is present Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 41/93] smsc95xx: fix stalled rx after link change Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 42/93] drm/i915/request: fix early tracepoints Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 43/93] dsa: mv88e6xxx: 6161: Use chip wide MAX MTU Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 44/93] dsa: mv88e6xxx: Fix MTU definition Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 45/93] dsa: mv88e6xxx: Include tagger overhead when setting MTU for DSA and CPU ports Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 46/93] e100: fix length calculation in e100_get_regs_len Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 47/93] e100: fix buffer overrun in e100_get_regs Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 48/93] RDMA/hns: Fix inaccurate prints Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 49/93] bpf: Exempt CAP_BPF from checks against bpf_jit_limit Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 50/93] selftests, bpf: Fix makefile dependencies on libbpf Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 51/93] selftests, bpf: test_lwt_ip_encap: Really disable rp_filter Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 52/93] net: ks8851: fix link error Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 53/93] Revert "block, bfq: honor already-setup queue merges" Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 54/93] scsi: csiostor: Add module softdep on cxgb4 Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 55/93] ixgbe: Fix NULL pointer dereference in ixgbe_xdp_setup Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 56/93] net: hns3: do not allow call hns3_nic_net_open repeatedly Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 57/93] net: hns3: keep MAC pause mode when multiple TCs are enabled Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 58/93] net: hns3: fix mixed flag HCLGE_FLAG_MQPRIO_ENABLE and HCLGE_FLAG_DCB_ENABLE Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 59/93] net: hns3: fix show wrong state when add existing uc mac address Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 60/93] net: hns3: fix prototype warning Greg Kroah-Hartman
2021-10-04 12:52 ` [PATCH 5.10 61/93] net: hns3: reconstruct function hns3_self_test Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 62/93] net: hns3: fix always enable rx vlan filter problem after selftest Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 63/93] net: phy: bcm7xxx: Fixed indirect MMD operations Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 64/93] net: sched: flower: protect fl_walk() with rcu Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 65/93] af_unix: fix races in sk_peer_pid and sk_peer_cred accesses Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 66/93] perf/x86/intel: Update event constraints for ICX Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 67/93] hwmon: (pmbus/mp2975) Add missed POUT attribute for page 1 mp2975 controller Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 68/93] nvme: add command id quirk for apple controllers Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 69/93] elf: dont use MAP_FIXED_NOREPLACE for elf interpreter mappings Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 70/93] debugfs: debugfs_create_file_size(): use IS_ERR to check for error Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 71/93] ipack: ipoctal: fix stack information leak Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 72/93] ipack: ipoctal: fix tty registration race Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 73/93] ipack: ipoctal: fix tty-registration error handling Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 74/93] ipack: ipoctal: fix missing allocation-failure check Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 75/93] ipack: ipoctal: fix module reference leak Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 76/93] ext4: fix loff_t overflow in ext4_max_bitmap_size() Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 77/93] ext4: limit the number of blocks in one ADD_RANGE TLV Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 78/93] ext4: fix reserved space counter leakage Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 79/93] ext4: add error checking to ext4_ext_replay_set_iblocks() Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 80/93] ext4: fix potential infinite loop in ext4_dx_readdir() Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 81/93] HID: u2fzero: ignore incomplete packets without data Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 82/93] net: udp: annotate data race around udp_sk(sk)->corkflag Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 83/93] ASoC: dapm: use component prefix when checking widget names Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 84/93] usb: hso: remove the bailout parameter Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 85/93] crypto: ccp - fix resource leaks in ccp_run_aes_gcm_cmd() Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 86/93] HID: betop: fix slab-out-of-bounds Write in betop_probe Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 87/93] netfilter: ipset: Fix oversized kvmalloc() calls Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 88/93] mm: dont allow " Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 89/93] HID: usbhid: free raw_report buffers in usbhid_stop Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 90/93] net: mdiobus: Fix memory leak in __mdiobus_register Greg Kroah-Hartman
2021-10-04 20:58   ` Florian Fainelli
2021-10-04 12:53 ` [PATCH 5.10 91/93] KVM: x86: Handle SRCU initialization failure during page track init Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 92/93] netfilter: conntrack: serialize hash resizes and cleanups Greg Kroah-Hartman
2021-10-04 12:53 ` [PATCH 5.10 93/93] netfilter: nf_tables: Fix oversized kvmalloc() calls Greg Kroah-Hartman
2021-10-04 16:31 ` [PATCH 5.10 00/93] 5.10.71-rc1 review Fox Chen
2021-10-04 18:08 ` Pavel Machek
2021-10-04 19:45 ` Shuah Khan
2021-10-04 20:48 ` Florian Fainelli
2021-10-05  2:40 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211004125034.665736576@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=haokexin@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).