Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2453987rwi; Fri, 28 Oct 2022 07:17:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6d5KphBSmk8KOn6YlCxMurWzxAruX4yJY4OPJkxTIC443Y83IIbxykAKd/MACMdpPRFcIZ X-Received: by 2002:a63:2a44:0:b0:46e:9fda:219b with SMTP id q65-20020a632a44000000b0046e9fda219bmr35933693pgq.347.1666966629371; Fri, 28 Oct 2022 07:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666966629; cv=none; d=google.com; s=arc-20160816; b=Q302ydgToMl4mGRSNIrTmJbw6DS2A/UgrdcFbfbRHfRWx9U36gbtjS+uMCa2wduUwh iC7sAyDGLzgIPCOzKRSHgk7CgkdWJxpcdUS6DOTcj7ytHJoI6q4T7aqTZNtemVQIqXo1 dxvrUZ1pg++k72we4IzTXn74Ip5mErcueS49nwj3qaknmATIckltOuwIj+ZpBHvY+Sq9 DLr/3te8PBOcbWd0mZ05X2IaZLe4yWsoLxlUXbo8KUO8t0h9t+f+OXRtpaY9zA5skc9m jvoQgW1FCjQwwHkXgagNwUHApzG9P2mAv6XRb/bMaqKI68YnM+KcfTJkhpplsPlPjYri uDCg== 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=Iq8udochiO3g+WEpiwdZU0+VcAkjE1uhEGuwOzPUifg=; b=rbRqGCjM8RQ9l4WryguQaJ0pSOo0K8CMVJMqHhZH25Cz0I5Hz2eDisQAT6BiOYHBUn eRj4arUReq1s8dzYqK7IzcBXXdpBDN+UO2Mcc1/bUkwXFtQmil2zR6B/H7QJFYsBzJbB N1aP8REozJoVBfd64pys3XVf8Wk0QVIlr7N7a1ufEVhAF1920LJ7iORCJGebNl8AlVmj rO2juUBI7+3NXDpWGAv388Y2OM2vJHsZEUEifRbFRtQi3/vZj6FxtBIe56vKdS4ru0nN jR7XQfKq3N3J1OEVa+Cle7taWRzkHtneLgXG0hLpJ3MzEKq06HpTc6EA3gjhXnrNuD4m eL8A== 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 ms19-20020a17090b235300b00211e0e9f18csi5103579pjb.40.2022.10.28.07.16.56; Fri, 28 Oct 2022 07:17:09 -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 S230495AbiJ1OAn (ORCPT + 99 others); Fri, 28 Oct 2022 10:00:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230334AbiJ1OAk (ORCPT ); Fri, 28 Oct 2022 10:00:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6359FB7F42; Fri, 28 Oct 2022 07:00:39 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 000BA6289B; Fri, 28 Oct 2022 14:00:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EF4FC433C1; Fri, 28 Oct 2022 14:00:36 +0000 (UTC) Date: Fri, 28 Oct 2022 10:00:52 -0400 From: Steven Rostedt To: Guenter Roeck , linux-scsi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Thomas Gleixner , Stephen Boyd , Greg Kroah-Hartman , Felipe Balbi , Johan Hovold , Alan Stern , Mathias Nyman , Kai-Heng Feng , Matthias Kaehlcke , Michael Grzeschik , Bhuvanesh Surachari , Dan Carpenter , linux-usb@vger.kernel.org, Lai Jiangshan , Tejun Heo , Jens Axboe , "James E.J. Bottomley" , "Martin K. Petersen" Subject: Re: [RFC][PATCH v2 20/31] timers: usb: Use del_timer_shutdown() before freeing timer Message-ID: <20221028100052.2e392127@gandalf.local.home> In-Reply-To: <20221028061422.139c54a7@gandalf.local.home> References: <20221027150525.753064657@goodmis.org> <20221027150928.983388020@goodmis.org> <4e61935b-b06b-1f2d-6c2b-79bdfd569cd6@roeck-us.net> <20221028061422.139c54a7@gandalf.local.home> 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 06:14:22 -0400 Steven Rostedt wrote: > On Thu, 27 Oct 2022 22:23:06 -0700 > Guenter Roeck wrote: > > > A similar call to INIT_DELAYED_WORK() around line 1085 needs the same change. > > > > It would be great if that can somehow be hidden in INIT_DELAYED_WORK(). > > I agree, but the delayed work is such a special case, I'm struggling to > find something that works sensibly. :-/ > OK, I diagnosed the issue here. The problem is that delayed work also has no "shutdown" method when it's done. Which means there's no generic way to call the work->timer shutdown method. So we have two options to handle delayed work timers: 1) Add special initialization for delayed work so that it can just go back to the old checking (activating on arming, deactivating by any del_timer*). 2) Implement a shutdown state for the work queues as well. There could definitely be the same types of bugs as with timers, where a delayed work could be pending on something that's been freed. That's probably why there's a DEBUG_OBJECTS_WORK too. Ideally, I would like to have #2, but realistically, I'm going for #1 for now. We could always add the work queue shutdown state later if we want. The problem with timers with respect to delayed work queues, is that there's no place to add the "shutdown" before its no longer in use. Worse yet, there's code that caches descriptors that have delayed work instead of freeing them. (See block/blk-mq.c and drivers/scsi/scsi_lib.c with the queuelist). Where it just calls del_timer(), and then sends it back to the free store for reuse later. Perhaps we should add DEBUG_OBJECTS checking to these too? Anyway, I'll make it where the INIT_DELAYED_WORK will call __timer_init_work() that will set the debug state in the timer to TIMER_DEBUG_WORK, were it will activate and deactivate the debug object on add_timer() and del_timer() and hope that it's not one of the bugs we are hitting :-/ -- Steve