Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5744564iob; Tue, 10 May 2022 02:39:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfuh3r3y8svabUkEFFNNXrMJL8xkzUgt1OMzMx/Uvv18jcWjYKFfKA3VAzqJ4mojN+LmTc X-Received: by 2002:a05:6a00:150a:b0:510:3ea4:4cd9 with SMTP id q10-20020a056a00150a00b005103ea44cd9mr19615420pfu.27.1652175555286; Tue, 10 May 2022 02:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652175555; cv=none; d=google.com; s=arc-20160816; b=YkjRAxA7x+p2dKi5Ihy+fSatDbIbPz05RmTmYP46o3RPqusMDZY4RO5FGsasgVHMcd 28brbpb+qGv+FSPO7jHNWYnng+WJZKv6Tw25pZFyTS+WRWdRu2T4THsWvQUW5DwiFB/9 4ytxNXVM7Bu7dUkaGO2OS9aAmKKTPiodUVwV6Dd4f10RYxPa2b96o/FVumGTbXNd4S5G 4wxHmVhCeIm2+YpciwblCJezt94a8tLNtUhr1B6cV5U/o+/OKABkaLSJAGlPEQwd+cS/ 0tY0w6lplrS28tFddlwzkgQEhIBoaJlm3ZHQKXfIoXSef7uyPqFfED/PfSoqIm3x0WMr zKnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=pGtYIOPDePSrNIMyokVXHcQNltfPtCMsxsULiEstEbQ=; b=0IgpGE9ec1wtQ6ChQ5N9zEx0/tsFmTVH62eieK0yDSw8PGQV8PzflMv1LpMRHkZLmn VZ/qYCSvwp4322/eeDwgpm54UNjul9q+xod+8a4M7rnG0cDCiDc7K85t7XLcKohsF6K3 VreFejyJwiNCWMbf8lRB1RndXAgos/7Dj/FR/iJwqtSO7RTFqmqcZT+Cz60v4PV0XOOG M8wxNcCBU1lZ6rgBYmjozQ3Z96GPc/ObCbn0TvR0c6W+GKfqg6W8HaO92JMis3NcrkfA +eRBQoBs/NhYRCCFRi/hkzB5B/pW5N8gs05C0CgyyR7l7QUmbs9OU0eBpeeyKHnHU7Dh qTjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=nPOgK6B8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=xh04S0rR; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p15-20020a056a000b4f00b00510496c4bd3si18671891pfo.250.2022.05.10.02.39.01; Tue, 10 May 2022 02:39:15 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=nPOgK6B8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=xh04S0rR; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233264AbiEJJYE (ORCPT + 99 others); Tue, 10 May 2022 05:24:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbiEJJYA (ORCPT ); Tue, 10 May 2022 05:24:00 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 022CE24310D for ; Tue, 10 May 2022 02:20:04 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1652174402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pGtYIOPDePSrNIMyokVXHcQNltfPtCMsxsULiEstEbQ=; b=nPOgK6B8c1YtqNNKXNUYD7yun57LoBc1wOBofPENs/rW4AXitbZvIY5rAPOwmW81HPL4Mh S6bLNwV6CkaooK1G6PpkEhHvbuvHHzFYOwT0y617LqGgoXdXNo8EMm2CQoxr/SwSdKGFK4 zgFtBJ8Q2Ptqu38c0eq0RgB3DYUij15qFF8MjWrMAmiZCAstyOhzPbf//xWp3beC/yGCMo ZIRSfGxpEOG8FTF/e92AcAwKtxuPhEH4MMzPVdvbVmEM/EpZu8DH9EuQN4k6unBxfdrFYY MTIYgCQEEzFyh2swIIQXST8+xCrGM+1GLMt8dkJ6dqpjRK5lzdp12DYAdaLAsw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1652174402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pGtYIOPDePSrNIMyokVXHcQNltfPtCMsxsULiEstEbQ=; b=xh04S0rRh1Uye/zo/UEkIPc5L5YhYfWvr0RuEbdr5lOMYV9CaWAWHS5uavl/A8wLcaa8V/ QxvpzoQ5MG9LEtDg== To: Stephen Boyd , John Stultz Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tejun Heo , Lai Jiangshan , Guenter Roeck Subject: Re: [PATCH] timers: Provide a better debugobjects hint for delayed works In-Reply-To: <20220504223148.644228-1-swboyd@chromium.org> References: <20220504223148.644228-1-swboyd@chromium.org> Date: Tue, 10 May 2022 11:20:01 +0200 Message-ID: <87sfphpwvy.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Wed, May 04 2022 at 15:31, Stephen Boyd wrote: > Provide better information here by special casing delayed works in the > timer debugobjects hint logic so that the work function is returned > instead of the timer function delayed_work_timer_fn(). This will help us > understand what delayed work was pending that got freed, leading to > faster bug resolutions. Makes sense. > --- > I have an alternative approach which is to treat delayed works with a > different debug_obj_descr structure but it basically boils down to > another version of timer debugobjects in the workqueue code. The idea is > to make the delayed work active once the timer is queued and then > convert it over from a delayed work descriptor to a work descriptor once > the timer runs delayed_work_timer_fn() or when we pull it off to flush > out. Nah. > #include > #include > @@ -617,7 +618,17 @@ static const struct debug_obj_descr timer_debug_descr; > > static void *timer_debug_hint(void *addr) > { > - return ((struct timer_list *) addr)->function; > + struct timer_list *timer = addr; > + > + if (timer->function == delayed_work_timer_fn) { > + struct delayed_work *dwork; > + > + dwork = container_of(timer, struct delayed_work, timer); > + > + return dwork->work.func; > + } The same issue exists for kthread_delayed_work_timer_fn. So maybe something like the uncompiled/untested below. Thanks, tglx --- --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -638,9 +638,35 @@ static void internal_add_timer(struct ti static const struct debug_obj_descr timer_debug_descr; +struct timer_hint { + void (*function)(struct timer_list *); + long offset; +}; + +#define TIMER_HINT(fn, container, timr, hintfn) \ + { \ + .function = fn, \ + .offset = offsetof(container, hintfn) - \ + offsetof(container, timr) \ + } + +static const struct timer_hint timer_hints[] = { + TIMER_HINT(delayed_work_timer_fn, + struct delayed_work, timer, work.func), + TIMER_HINT(kthread_delayed_work_timer_fn, + struct kthread_delayed_work, timer, work.func), +}; + static void *timer_debug_hint(void *addr) { - return ((struct timer_list *) addr)->function; + struct timer_list *timer = addr; + int i; + + for (i = 0; i < ARRAY_SIZE(timer_hints); i++) { + if (timer_hints[i].function == timer->function) + return addr + timer_hints[i].offset; + } + return timer->function; } static bool timer_is_static_object(void *addr)