Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6159579rwb; Tue, 22 Nov 2022 09:28:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf533UZ/aapYJ9vnGdh2IxjJLhSXPFOPv0FaO97fs4y3E0JtCk3mx63WMrst4nCR17LWngn7 X-Received: by 2002:a05:6a00:1696:b0:571:2b7c:6693 with SMTP id k22-20020a056a00169600b005712b7c6693mr7466387pfc.48.1669138135945; Tue, 22 Nov 2022 09:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669138135; cv=none; d=google.com; s=arc-20160816; b=p3brHpJ3L5Otv1Bdf9g4HzAI4QQQ9a0Qgp319wTDIzTEu54MvgSyuSlcga3IcswLBh U+1w64TG7B44rGe86NwJSuEwuJ60vhf2FoYRGqH0gzZYUDD4WpvJRemT4u3POFZHiRyq S8PMQNjuGeAQdLV4mC+TBa11/u4njXYR09IemqaxCOFXko94BVOkZKZh2Y5S0OWXcOx2 sNbe/krkNSENN7bQc18AKRn8l4i6r1L1Ibyeoy99wt/yYhKxocl2XZ4av0jGO9jOHOVK zToX+zLcAj5d1DW6hoeYdGIRst9i3ev9Qq9dFA/SaXXQpI+IpYJm6G/nA+mAhLCbIA2K 6UQw== 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=Sr+RUCjgcBEdnVRCtlKz07taeir/JnCljJn1cAo2zwg=; b=CIXj6NozstsAxk+3vlTS6ZihTA+cEfh0tUtDlJaOLVCpBl8WhoaC0OFMQIf1HTc4WU XlT8X1zQsLjECAt0DVynAvGcYALGLJ3JwvJs6bXSKckkq9z4V7E/Lvl1AaT0IRgH1Uwi LquVdkUCQ4fweJvM/VTKdn+ugPB9MeuJv4Ih3KigQ9hNHcqzSd/H2/XsUn7TRVxGkCQI bVeFKzWZi8sVBU4i97SFfMWRPRbMf5oYJ5JoxnJ7+QsDG1GluOrFXVrhlwQljZP1T3fT IXmHefqrdxwQbx8TeOmZmufdIru/Gn1bTv52bseyYKR8ACz9zVwtBWc24uk38GaJows3 h1Vg== 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 k14-20020a170902ce0e00b001869347b0besi14574000plg.174.2022.11.22.09.28.45; Tue, 22 Nov 2022 09:28:55 -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 S234466AbiKVROK (ORCPT + 90 others); Tue, 22 Nov 2022 12:14:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234453AbiKVROI (ORCPT ); Tue, 22 Nov 2022 12:14:08 -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 E63AF6E577; Tue, 22 Nov 2022 09:14:07 -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 8A7FA100DCEC0; Tue, 22 Nov 2022 18:14:06 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 6BAF4A236D; Tue, 22 Nov 2022 18:14:06 +0100 (CET) Date: Tue, 22 Nov 2022 18:14:06 +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" , Thomas Gleixner Subject: Re: [PATCH V2] PCI/DOE: Detect on stack work items automatically Message-ID: <20221122171406.GC11310@wunner.de> References: <20221118000524.1477383-1-ira.weiny@intel.com> <20221122171309.GA11310@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221122171309.GA11310@wunner.de> 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 Now with Thomas added to cc for real. On Tue, Nov 22, 2022 at 06:13:09PM +0100, Lukas Wunner wrote: > [+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