Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1703940rwi; Thu, 27 Oct 2022 20:30:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4yBYCA5IfrARIdY27/aAy4NKPX5vQFRRH9pgdz4RUy8Czq4656Ccm7ZVuvBpZ4leM07XZU X-Received: by 2002:a17:907:783:b0:76e:f290:8b5 with SMTP id xd3-20020a170907078300b0076ef29008b5mr45863414ejb.395.1666927821266; Thu, 27 Oct 2022 20:30:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666927821; cv=none; d=google.com; s=arc-20160816; b=ZH65IYNxormkAW35IJf8Ab0+SP3dBwsYUCo0kIclctqoRZFQDk6afEEdiHnaAdb6jo IgLPHcNqmpaWD1FmVW7MqPFQiQlEs5cuDAAGZYgusD67uxvnw9li+a7tJWLn8K+pcTtW fLWAzUEbwzZQeut6yQ9O0uCrgKq8kFcEvKU1u3AiqUFArbTJdZkGu2d9+6Hc4YwN9pSw cek5Am+MRdRyWKlBuiKw7x/aAXJI/56zzCWYolavxvuMk1j0Zyvc3VTnuVwX+gJPYAJB V9wqtUaXIFLe/S8hHQoykF1/2sDDSP+xvOwOjyNDBvM6qSQy1s7BMtzDU7Z5/m5RI/RN InlA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Gu6Y6iw5BXcl/qB30cApFW6y0QGBTynN8Q2N7DeAync=; b=R4hpnrU7l3JWEE3CT//xlAV9K+rJ0QC93AEWxuYriEpeRZvQQrqL3/oUqL06HlSx6M DOLaHu1tnr5ZTOF68nviJIsBKSODy0+iaUPQuOo6Zet/1dglWNirk3cjttlbJujceL9T nYtyM0gsj+vf/TRyxQn7mzHQDCFoN4o+zQN0YFRdhWCc9O2fA2Ap8kcNjaZrW91+HR6c KO7LllVWTiIHCSeu6caSwrue+mSfQrVQgLWy60dbk+w4hI/Hq6kz2eisjoV+CQSj1SXp LBU8frwqsyNXaTSin69DukGjTK9hXoyWVMJe4VTS8nLWB0csB+XumAXAWBzr3/N8UsGu evNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm15-20020a170907948f00b0079a9eed8c1bsi3215375ejc.894.2022.10.27.20.29.54; Thu, 27 Oct 2022 20:30:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235441AbiJ1DRi (ORCPT + 99 others); Thu, 27 Oct 2022 23:17:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235743AbiJ1DRW (ORCPT ); Thu, 27 Oct 2022 23:17:22 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33DCA59E9B; Thu, 27 Oct 2022 20:17:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 4D975CE1346; Fri, 28 Oct 2022 03:17:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E01D7C433D6; Fri, 28 Oct 2022 03:17:11 +0000 (UTC) Date: Thu, 27 Oct 2022 23:17:27 -0400 From: Steven Rostedt To: Hillf Danton Cc: linux-kernel@vger.kernel.org, Alan Stern , Dan Carpenter , linux-usb@vger.kernel.org Subject: Re: [RFC][PATCH v2 20/31] timers: usb: Use del_timer_shutdown() before freeing timer Message-ID: <20221027231727.4469d81c@gandalf.local.home> In-Reply-To: <20221028021815.3130-1-hdanton@sina.com> References: <20221027150525.753064657@goodmis.org> <20221028021815.3130-1-hdanton@sina.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 28 Oct 2022 10:18:15 +0800 Hillf Danton wrote: > On 27 Oct 2022 11:05:45 -0400 Steven Rostedt (Google) > > > > --- a/drivers/usb/core/hub.c > > +++ b/drivers/usb/core/hub.c > > @@ -1261,6 +1261,9 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) > > > > /* Don't do a long sleep inside a workqueue routine */ > > if (type == HUB_INIT2) { > > + /* Timers must be shutdown before they are re-initialized */ > > + if (hub->init_work.work.func) > > + del_timer_shutdown(&hub->init_work.timer); > > This is not needed in the workqueue callback as the timer in question > is not pending. This was added because of the updates to DEBUG_OBJECTS_TIMERS that changed it to require a shutdown to remove the activation of the timer. This is to detect the possibility that a timer may become active just before freeing (there's way too many bugs that show that code logic is not enough). This code in particular is troubling because it re-initializes an already initialized timer with a new function. This causes the debug-objects to trigger an "object activated while initializing" warning. I originally added the "shutdown" to deactivate the object before you re-initialize it. But I have since updated the code to keep track of if it was ever activated, and if so, not to call the init code again, so this may not be required anymore. I'm still trying to work out the kinks as the users of timers have become adapted to the implementation, and may need to add some other helpers to make this work. -- Steve > > > INIT_DELAYED_WORK(&hub->init_work, hub_init_func3); > > queue_delayed_work(system_power_efficient_wq, > > &hub->init_work,