Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6159000rwb; Tue, 22 Nov 2022 09:28:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf6pDTcsYGCiHR0b7yX2R+jQkirpDyffbboHDgLH25QYnai4IR83IQ56TbZz3tgVUJb2V8fb X-Received: by 2002:a17:902:ef81:b0:188:d41f:c37b with SMTP id iz1-20020a170902ef8100b00188d41fc37bmr5147997plb.132.1669138108448; Tue, 22 Nov 2022 09:28:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669138108; cv=none; d=google.com; s=arc-20160816; b=DJMOIJaRbjD2fL/RHlvc8lc/eiXT+ZJ1TTuMZzar8IorIOlN3RusG8dPwcGtN3mN48 rt4iC9LvzplI0EF5pRSQd/6aUmSAqouWODe9s4nrfaPYZk78Mfmi/xnmbhtucL1qSHCi GcG5YYm4cLhE2jZhA/8/M0Li2QnwZIllsMrgELn4BehFxQZ0YAl8shPt+fv+UUd0bVts 6dkbET9niF6jxMP0xN+eo9dyUaId2WjwJU2km0dcMP8clm/jeFXRUibooM2nJwBFlq5G iA1fdGQyJAq1oLac9TK8o2LfJ8zf5ou2a6D8AYEu2QPj5BOJocVBE6ka+gpqsO5VdFkt qgFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=vwhJWnXIbQuL5OObpAFje2qxX105QOLv/nprU+3Xeb8=; b=bS7wa4Ww10Qmf/mc5lnltR0kCDHrAcKksqzR85oh6GqBNbJAOx7sQ2Z0wgOqNBSWGn ZtVp6pw5TAIUYbgpNngI0icITuTNlesPCG8xmA/4/nMfGxGVat6twzXmHZk1tpr/idAq WwC3AQcnlIwmC9/G9X3vEGRsQIQsN3ySqUpAagry0sQ2wL6GpnmhtQVsDRb8o1o/U+Ko jnZcWUK9FUn5JcnVUoWXGVNt19QCOf5FG92QYJjduNIarqxsHw4m542j6MLXKkK0a8Xn qrYNAoiTGtOJTUVatH7JQO/mX7A8/wsPTnX+7w8u/A7f4EcRdDbvX0iS9LLsVfKBGyef tOrA== 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 l6-20020a170903120600b00186c3afbd25si16401202plh.349.2022.11.22.09.28.17; Tue, 22 Nov 2022 09:28:28 -0800 (PST) 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 S234454AbiKVRNP (ORCPT + 90 others); Tue, 22 Nov 2022 12:13:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233436AbiKVRNN (ORCPT ); Tue, 22 Nov 2022 12:13:13 -0500 Received: from bmailout3.hostsharing.net (bmailout3.hostsharing.net [IPv6:2a01:4f8:150:2161:1:b009:f23e:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFDBB6E577; Tue, 22 Nov 2022 09:13:11 -0800 (PST) Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS DV RSA Mixed SHA256 2020 CA-1" (verified OK)) by bmailout3.hostsharing.net (Postfix) with ESMTPS id 15070100DA1A0; Tue, 22 Nov 2022 18:13:10 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id D6296A072C; Tue, 22 Nov 2022 18:13:09 +0100 (CET) Date: Tue, 22 Nov 2022 18:13:09 +0100 From: Lukas Wunner To: David Laight Cc: "'ira.weiny@intel.com'" , Bjorn Helgaas , Dan Williams , Bjorn Helgaas , Gregory Price , Jonathan Cameron , Vishal Verma , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-cxl@vger.kernel.org" Subject: Re: [PATCH V2] PCI/DOE: Detect on stack work items automatically Message-ID: <20221122171309.GA11310@wunner.de> References: <20221118000524.1477383-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE 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 [+cc Thomas Gleixner, author of dc186ad741c1] On Fri, Nov 18, 2022 at 09:20:38AM +0000, David Laight wrote: > > From: ira.weiny@intel.com > > Sent: 18 November 2022 00:05 > > > > Work item initialization needs to be done with either > > INIT_WORK_ONSTACK() or INIT_WORK() depending on how the work item is > > allocated. > > > > The callers of pci_doe_submit_task() allocate struct pci_doe_task on the > > stack and pci_doe_submit_task() incorrectly used INIT_WORK(). > > > > Jonathan suggested creating doe task allocation macros such as > > DECLARE_CDAT_DOE_TASK_ONSTACK().[1] The issue with this is the work > > function is not known to the callers and must be initialized correctly. > > > > A follow up suggestion was to have an internal 'pci_doe_work' item > > allocated by pci_doe_submit_task().[2] This requires an allocation which > > could restrict the context where tasks are used. > > > > Another idea was to have an intermediate step to initialize the task > > struct with a new call.[3] This added a lot of complexity. > > > > Lukas pointed out that object_is_on_stack() is available to detect this > > automatically. > > > > Use object_is_on_stack() to determine the correct init work function to > > call. > > This is all a bit strange. > The 'onstack' flag is needed for the diagnostic check: > is_on_stack = object_is_on_stack(addr); > if (is_on_stack == onstack) > return; > pr_warn(...); > WARN_ON(1); > > So setting the flag to the location of the buffer just subverts the check. > It that is sane there ought to be a proper way to do it. If object_is_on_stack() is sufficient to check whether a struct is on the stack or not, why doesn't __init_work() use it to auto-detect whether to call debug_object_init_on_stack() or debug_object_init()? Forcing developers to use a specific initializer for something that can be auto-detected is akin to treating them like kids and telling them "You didn't say the magic word." What's the point? Thanks, Lukas