From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753210AbbCJNUO (ORCPT ); Tue, 10 Mar 2015 09:20:14 -0400 Received: from mga11.intel.com ([192.55.52.93]:61497 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751620AbbCJNUL convert rfc822-to-8bit (ORCPT ); Tue, 10 Mar 2015 09:20:11 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,374,1422950400"; d="scan'208";a="465161783" From: "Du, Changbin" To: Tejun Heo CC: "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] workqueue: detect uninitated work_struct and BUG() if true Thread-Topic: [PATCH] workqueue: detect uninitated work_struct and BUG() if true Thread-Index: AdBaI1yW6nMH7HUnRzyBk9sYhfyxOf//lhGA//1zs8A= Date: Tue, 10 Mar 2015 13:20:02 +0000 Message-ID: <0C18FE92A7765D4EB9EE5D38D86A563A01C9356F@SHSMSX103.ccr.corp.intel.com> References: <0C18FE92A7765D4EB9EE5D38D86A563A01C85B55@SHSMSX103.ccr.corp.intel.com> <20150309062243.GL13283@htj.duckdns.org> In-Reply-To: <20150309062243.GL13283@htj.duckdns.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Tejun Heo [mailto:htejun@gmail.com] On Behalf Of Tejun Heo > Sent: Monday, March 9, 2015 2:23 PM > To: Du, Changbin > Cc: linux-kernel@vger.kernel.org > Subject: Re: [PATCH] workqueue: detect uninitated work_struct and BUG() if > true > > @@ -1295,6 +1295,9 @@ static void __queue_work(int cpu, struct > workqueue_struct *wq, > > */ > > WARN_ON_ONCE(!irqs_disabled()); > > > > + if (!work->func) > > + BUG(); > > + > > debug_work_activate(work); > > Can't this be part of the debug_work mechanism? I'm a bit wary of adding > essentially arbitrary checks. I'd much prefer if it gets gated by debug config > somehow. > > Thanks. > Tejun Yes, I found there already have this checking and print a warning in work_fixup_activate. So this patch can be droped. Thanks for point out. static int work_fixup_activate(void *addr, enum debug_obj_state state) { struct work_struct *work = addr; switch (state) { case ODEBUG_STATE_NOTAVAILABLE: /* * This is not really a fixup. The work struct was * statically initialized. We just make sure that it * is tracked in the object tracker. */ if (test_bit(WORK_STRUCT_STATIC_BIT, work_data_bits(work))) { debug_object_init(work, &work_debug_descr); debug_object_activate(work, &work_debug_descr); return 0; } WARN_ON_ONCE(1);