From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422824AbcBZS4f (ORCPT ); Fri, 26 Feb 2016 13:56:35 -0500 Received: from smtprelay0164.hostedemail.com ([216.40.44.164]:58839 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1422839AbcBZS4c (ORCPT ); Fri, 26 Feb 2016 13:56:32 -0500 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2553:2559:2562:2895:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3871:3872:4321:4385:5007:6119:6120:6261:7875:7903:8660:9163:10004:10400:10848:10967:11026:11232:11658:11914:12043:12295:12296:12438:12517:12519:12555:12740:13148:13230:14096:14097:14659:21060:21080:30029:30054:30056:30070:30075:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: use45_9011e492bfc1f X-Filterd-Recvd-Size: 3409 Date: Fri, 26 Feb 2016 13:56:28 -0500 From: Steven Rostedt To: Yang Shi Cc: gregkh@linuxfoundation.org, tj@kernel.org, lizefan@huawei.com, tglx@linutronix.de, bigeasy@linutronix.de, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, linaro-kernel@lists.linaro.org Subject: Re: [RFC PATCH] kernfs: create raw version kernfs_path_len and kernfs_path Message-ID: <20160226135628.09ce727c@gandalf.local.home> In-Reply-To: <1456510505-6620-1-git-send-email-yang.shi@linaro.org> References: <1456510505-6620-1-git-send-email-yang.shi@linaro.org> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.29; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 26 Feb 2016 10:15:05 -0800 Yang Shi wrote: > commit 5634cc2aa9aebc77bc862992e7805469dcf83dac ("writeback: update writeback > tracepoints to report cgroup") made writeback tracepoints report cgroup > writeback, but it may trigger the below bug on -rt kernel since kernfs_path > and kernfs_path_len are called by tracepoints, which acquire sleeping lock. > > BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:930 > in_atomic(): 1, irqs_disabled(): 0, pid: 625, name: kworker/u16:3 > INFO: lockdep is turned off. > Preemption disabled at:[] wb_writeback+0xec/0x830 > > CPU: 7 PID: 625 Comm: kworker/u16:3 Not tainted 4.4.1-rt5 #20 > Hardware name: Freescale Layerscape 2085a RDB Board (DT) > Workqueue: writeback wb_workfn (flush-7:0) > Call trace: > [] dump_backtrace+0x0/0x200 > [] show_stack+0x24/0x30 > [] dump_stack+0x88/0xa8 > [] ___might_sleep+0x2ec/0x300 > [] rt_spin_lock+0x38/0xb8 > [] kernfs_path_len+0x30/0x90 > [] trace_event_raw_event_writeback_work_class+0xe8/0x2e8 > [] wb_writeback+0x620/0x830 > [] wb_workfn+0x61c/0x950 > [] process_one_work+0x3ac/0xb30 > [] worker_thread+0x9c/0x7a8 > [] kthread+0x190/0x1b0 > [] ret_from_fork+0x10/0x30 > > Since kernfs_* functions are heavily used by cgroup, so it sounds not > reasonable to convert kernfs_rename_lock to raw lock. > > Create raw version kernfs_path, kernfs_path_len and cgroup_path, which don't > acquire lock and are used by tracepoints only. > And what prevents name from being freed while the tracepoint is reading it? Perhaps we need this change as well: -- Steve diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 996b7742c90b..d2ef153145c0 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -1397,6 +1397,12 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent, kn->hash = kernfs_name_hash(kn->name, kn->ns); kernfs_link_sibling(kn); + /* + * Tracepoints may be reading the old name. They are protected + * by rcu_read_lock_sched(). + */ + synchronize_sched(); + kernfs_put(old_parent); kfree_const(old_name);