Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1306412pxa; Sat, 15 Aug 2020 15:14:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzobGJ1ej3eOs39E2t0dVKH8+BIHAZb3sjCtzrD7TlG0pZMDLbdxFC0ucV0qDbD82yagOCy X-Received: by 2002:a17:906:8490:: with SMTP id m16mr8475407ejx.132.1597529670180; Sat, 15 Aug 2020 15:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597529670; cv=none; d=google.com; s=arc-20160816; b=E7lOCbzWCR+sJGoL2UxqL7ORavgynjkxxGJjwB7JZnf2/jI3ZTmNifs9ACsfgH/WDa QDnd4xiBmJM3Qoiud90mnAE+QKCjFxR3KASe5+0fpCt2hZMZFBGt0HOHuC3qp8PR1Jm4 fw1bvMNkNsdrCjjBaIq9s6vb4ZBvDa4icf5GaP9Tsbjqcx9DuwaS5Tb6esRs/ug3zoJ8 u9UrkeSwc7M3pEF0Q9Gk7ajkNk+cGIQ3jbSTJvpIicTyde8HzF8yltlvg6iw6dDxrsJ9 bIKrZbm86GYt98w1hizWztZpoPSyBFL94Fl1j70rJ6r0whRZyO71jmMcq+QDlDRI/HPW fURg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:date:to:cc:from :subject:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=VGRj6YJNU7gRSNu8zsnEa7o2vV1mPHltSksx614+pgw=; b=vuAvcHWnXLJjzOSi1EeZovvBPgS5Qxzevz6VubA5MTa9KqzJCXqzq5nbJ9coACjupF 6MyAlJ04QEhYpxs67Ap/0adAK7AQSsVs1T/k1g5NModnpVmC++hOxn/ZEKvclRYpEKRG FJ8p4830x4PzwXbpqFpAAJK18ZTq+NlxRmez5UpPA7SEX8FVjLH91ZKIJt/QEMKYvjkW N7ZB1EJzCBMlsIWM+TGqoryQA3iPNo91dTYUDlxf7pXikzCREBKvGLd1XwN2QZs1zuXz SxQA5zHrK+wvdcBuocu5Ud4fUQRKqQnnAW32Gyu8Di7vhQ5/jy1YQY02hOZruSF9WyDb pr/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MfbojFz5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rp10si8143648ejb.323.2020.08.15.15.14.07; Sat, 15 Aug 2020 15:14:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MfbojFz5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729924AbgHOWLG (ORCPT + 99 others); Sat, 15 Aug 2020 18:11:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:41778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729480AbgHOWKb (ORCPT ); Sat, 15 Aug 2020 18:10:31 -0400 Received: from kernel.org (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4896D22EBD; Sat, 15 Aug 2020 08:37:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597480647; bh=Ku0SprNe4DSbL0fK2tkhd+WpmF55XeOtbZCh6UEp9+8=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=MfbojFz5eet5HSIuc5i++p49o3r2LZpQ9Ky4vvJrTDQlWVTH9JIFYtNh90GqQ29+h lPChbFEFyjhk7AOzomFtyIr5CLK55PPIRFUm6bCSN4R91sIh1iHoQI1tdUp+ciaK/G 16EiYM8TRgNjfIWPzLKmTc/FbjCD98wPyim0X7D4= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <87pn7w5fd4.fsf@nanos.tec.linutronix.de> References: <311159bc826dcca2848344fc277c0069cff0a164.1597207603.git.zhaoqianli@xiaomi.com> <159722125596.33733.17725649536425524344@swboyd.mtv.corp.google.com> <87pn7w5fd4.fsf@nanos.tec.linutronix.de> Subject: Re: [RFC V2] kthread: add object debug support From: Stephen Boyd Cc: john.stultz@linaro.org, ben.dooks@codethink.co.uk, bfields@redhat.com, cl@rock-chips.com, linux-kernel@vger.kernel.org, zhaoqianli@xiaomi.com To: Felix.Kuehling@amd.com, Qianli Zhao , Thomas Gleixner , akpm@linux-foundation.org, axboe@kernel.dk Date: Sat, 15 Aug 2020 01:37:26 -0700 Message-ID: <159748064613.2270147.9288160745183605164@swboyd.mtv.corp.google.com> User-Agent: alot/0.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Thomas Gleixner (2020-08-12 03:27:03) > Stephen, >=20 > Stephen Boyd writes: > > Quoting Qianli Zhao (2020-08-11 22:14:14) > >> +/********** kernel/kthread **********/ > >> +#define KWORK_ENTRY_STATIC ((void *) 0x600 + POISON_POINTER_DELTA) > > > > Is this related to the debugobjects change here? It looks like another > > version of list poison. >=20 > Yes, it is. We use these poison entries to mark statically allocated > objects. debug objects does not know about statically initialized > objects up to the point where they are used (activated). >=20 > That means the object state lookup will fail which causes debugobjects > to complain about using an uninitialized object. But in case of static > initialized ones that's a false positive. So we mark these objects in > their list head (or some other appropriate place) with a poison value > and in case of a failed lookup debug object does: >=20 > if (descr->is_static_object && descr->is_static_object(addr)) { > /* track this static object */ > debug_object_init(addr, descr); > debug_object_activate(addr, descr); > } =20 >=20 > The object specific is_static_object() callback will then check for the > magic list poison value being present: Thanks! I missed this function below. >=20 > > +static bool kwork_is_static_object(void *addr) > > +{ > > + struct kthread_work *kwork =3D addr; > > + > > + return (kwork->node.prev =3D=3D NULL && > > + kwork->node.next =3D=3D KWORK_ENTRY_STATIC); > > +} >=20 > and if so the debug object core fixes its internal state by creating a > tracking object and then activating it. >=20 > It's not a perfect "yes this is statically initialized" check but good > enough. If you go and do: >=20 > work =3D kzalloc(sizeof(*work); > work->node.next =3D KWORK_ENTRY_STATIC; >=20 > kthread_insert_work(worker, work); >=20 > or any other variant of insanity which makes the check claim that this > is statically initialized then you rightfully can keep the pieces :) Makes sense. Maybe this "technique" should be documented in Documentation/core-api/debug-objects.rst? I can cook up a patch to add is_static_object() to the Fixup functions section.