From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28959C678DB for ; Sat, 4 Mar 2023 11:48:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 170086B0072; Sat, 4 Mar 2023 06:48:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F8146B0073; Sat, 4 Mar 2023 06:48:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F02106B0074; Sat, 4 Mar 2023 06:48:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D98346B0072 for ; Sat, 4 Mar 2023 06:48:23 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9AA67C02A9 for ; Sat, 4 Mar 2023 11:48:23 +0000 (UTC) X-FDA: 80531042886.28.E02F5E7 Received: from r3-21.sinamail.sina.com.cn (r3-21.sinamail.sina.com.cn [202.108.3.21]) by imf23.hostedemail.com (Postfix) with ESMTP id 2FDAD14000B for ; Sat, 4 Mar 2023 11:48:18 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf23.hostedemail.com: domain of hdanton@sina.com designates 202.108.3.21 as permitted sender) smtp.mailfrom=hdanton@sina.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677930502; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZdxudAfenkkkqynsrz0nw5vXKkkLSgt0WbTZuo97vFk=; b=gbGQ1DtC69vcnJ2U+h1HPyZs+xk4DyebY2+/37Cm0YMswpjoumCCGKRTPgLAPomvo8WsOM GAaSvq/QCYwOh2kOqzYFsi6VcF3nJ5ZtsWcfkxwhPF90Y/OLMovmkwKUKClprA4KwXAdst U5RAg9w6krVDgik+qw+UuvkraWi4bKo= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf23.hostedemail.com: domain of hdanton@sina.com designates 202.108.3.21 as permitted sender) smtp.mailfrom=hdanton@sina.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677930502; a=rsa-sha256; cv=none; b=dbJlgT7uvhvQYWXEg/IIeR1A2s3Z/9z2aKSl4IIwjNCihtx4taBy3XwGVUOj34fYQWxmsE FFoj6xnbQjuzfCRl3IKR6J990P6ROMgxSddBVUJxhrFW1H9X8DYnyJLQwsdNmXfCr8n6WF pgcWsk0KBNoxxKCJJiu1OGOK/Pmp6O0= Received: from unknown (HELO localhost.localdomain)([114.249.61.130]) by sina.com (172.16.97.32) with ESMTP id 64032FEB000119C9; Sat, 4 Mar 2023 19:47:56 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 940640628896 From: Hillf Danton To: Thomas Gleixner Cc: Schspa Shi , Waiman Long , swboyd@chromium.org, linux@roeck-us.net, wuchi.zero@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzbot+5093ba19745994288b53@syzkaller.appspotmail.com Subject: Re: [PATCH 1/2] debugobject: fix concurrency issues with is_static_object Date: Sat, 4 Mar 2023 19:48:04 +0800 Message-Id: <20230304114804.2746-1-hdanton@sina.com> In-Reply-To: <875ybhjrtu.ffs@tglx> References: <20230303161906.831686-1-schspa@gmail.com> <814636e6-9a8a-9ab1-03a0-ed3702024227@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam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NoQ FFyfKFkm 2X3JOQwv1lNHaLD/8bAMNEsc1Avd12ixB6rsHGf630Ao8+XuVIX/4NNeUCqOL6DmmqMYbgCRunL+XCjK0C0JXwD2uDz28GTSmosj5sDQWDenLVd69a1Fl7mEe9gI0W3LpOoqT2mCXWOlig/ZEjv7BTm0RQKZKvfPXKnPU83jZEbkgnROZIQDmo3jUiKCyAR2umd3r+wXFkRpXFRLAE5xEMElfDWyjdKDRVRQ29YB8dI23Zvw6wmVUFkfLhUGB/SRNAEDa/OBNTG3u/3JLwZDuYwJeuvHZdZLzeDNODpysU2PUAew= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, 04 Mar 2023 01:14:21 +0100 Thomas Gleixner > On Sat, Mar 04 2023 at 01:53, Schspa Shi wrote: > > Waiman Long writes: > >>> diff --git a/include/linux/debugobjects.h b/include/linux/debugobjects.h > >>> index 32444686b6ff4..544a6111b97f6 100644 > >>> --- a/include/linux/debugobjects.h > >>> +++ b/include/linux/debugobjects.h > >>> @@ -30,6 +30,7 @@ struct debug_obj { > >>> enum debug_obj_state state; > >>> unsigned int astate; > >>> void *object; > >>> + bool is_static; > >>> const struct debug_obj_descr *descr; > >>> }; > >> > >> The patch looks reasonable. My main concern is the increase in size of the > >> debug_obj structure. It is an additional 8 bytes on 64-bit arches. How much will > >> we save performance-wise by caching it in the debug_obj. Alternatively, you may > >> pack it within the current size by, maybe, reducing the size of state. > >> > > > > Yes, we can change this to: > > > > struct debug_obj { > > struct hlist_node node; > > struct { > > enum debug_obj_state state : 31; > > bool is_static : 1; > > }; > > and thereby making debugobjects even more slower than it is right > now. Please check the resulting assembly code before proposing quick > "solutions". > > Thanks, > > tglx Add a debug flag to timer instead in order to make timer_is_static_object() depend no longer on TIMER_ENTRY_STATIC. Then it always gives the correct answer in every context. Hillf +++ y/include/linux/timer.h @@ -18,6 +18,10 @@ struct timer_list { void (*function)(struct timer_list *); u32 flags; +#ifdef CONFIG_DEBUG_OBJECTS_TIMERS + u32 is_static; +#define TIMER_IS_STATIC_MAGIC 0xFBFBBEEF +#endif #ifdef CONFIG_LOCKDEP struct lockdep_map lockdep_map; #endif @@ -73,6 +77,17 @@ struct timer_list { #define TIMER_TRACE_FLAGMASK (TIMER_MIGRATING | TIMER_DEFERRABLE | TIMER_PINNED | TIMER_IRQSAFE) + +#ifdef CONFIG_DEBUG_OBJECTS_TIMERS +#define __TIMER_INITIALIZER(_function, _flags) { \ + .entry = { .next = TIMER_ENTRY_STATIC }, \ + .function = (_function), \ + .flags = (_flags), \ + .is_static = TIMER_IS_STATIC_MAGIC, \ + __TIMER_LOCKDEP_MAP_INITIALIZER( \ + __FILE__ ":" __stringify(__LINE__)) \ + } +#else #define __TIMER_INITIALIZER(_function, _flags) { \ .entry = { .next = TIMER_ENTRY_STATIC }, \ .function = (_function), \ @@ -80,6 +95,7 @@ struct timer_list { __TIMER_LOCKDEP_MAP_INITIALIZER( \ __FILE__ ":" __stringify(__LINE__)) \ } +#endif /* CONFIG_DEBUG_OBJECTS_TIMERS */ #define DEFINE_TIMER(_name, _function) \ struct timer_list _name = \ +++ y/kernel/time/timer.c @@ -677,8 +677,7 @@ static bool timer_is_static_object(void { struct timer_list *timer = addr; - return (timer->entry.pprev == NULL && - timer->entry.next == TIMER_ENTRY_STATIC); + return timer->is_static == TIMER_IS_STATIC_MAGIC; } /* @@ -775,6 +774,7 @@ static const struct debug_obj_descr time static inline void debug_timer_init(struct timer_list *timer) { debug_object_init(timer, &timer_debug_descr); + timer->is_static = 0; } static inline void debug_timer_activate(struct timer_list *timer) @@ -804,6 +804,7 @@ void init_timer_on_stack_key(struct time { debug_object_init_on_stack(timer, &timer_debug_descr); do_init_timer(timer, func, flags, name, key); + timer->is_static = 0; } EXPORT_SYMBOL_GPL(init_timer_on_stack_key);