Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp439806rwb; Wed, 16 Nov 2022 02:59:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf4vjVlg1akPjusJr2GVfsQeVgwjA4dASk6Ctqzl8R9SsOp8AHohneGJ4oFnRwb2qXdnxr9H X-Received: by 2002:a17:907:c00c:b0:7ae:fbe6:e7ca with SMTP id ss12-20020a170907c00c00b007aefbe6e7camr10951606ejc.408.1668596370798; Wed, 16 Nov 2022 02:59:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668596370; cv=none; d=google.com; s=arc-20160816; b=cxRsxCotu0XNq1JIHFFfny622wC2zHCBYIunhZeqVMUbYbEUJDMm7mhhXIm6M8wIZt HR6Fk8pLsgHATTFb4gAwmdNKnWfiKOtA9VJE61X9Wu/hMpzcex6qLh4r5Yc+qSzRJFHr 2hnt2hKGSnuKPxn6g0/F+FcadQv3tN1+mO496MQWAKTh3gRqUasvPq1DuNv9Z4lQXlBB QK0h4GeUJaoLHUglxptwDmICaUjukHHEZ314zalM2ZGldgm1Dirqgf8HsR23ZXQH2UD/ Xhr7PcSl4Az6oO4dF5C4Nqo2GMyFXvllZEFbzpHKXXMJC7MR+JDlF54M3TwAoj581jEd TXJQ== 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=p+mREgfXn9K2uc41GrZZvLMdO+Fw5F6eTqtPzBM7chM=; b=QfTA8plolrB5B8rJAGmvsqITwOxqP7QhEvOQPkmZMAhvcHzJMCBdhmJlJ+dplriL7y UHm8BuWEbl9AwOMx+jIw5BiuXCJAhxp6BfJyzhPzHODdZ1aSajtBFIsUhVMc6ZePOsIu KxHIbUskhLNyXc7Nd25Vl11bevAJR+umMURxHI35AsWvGTJ65IxJ3uUtWXtW3ro2iGJZ 2jLFJo+lehzlszR2PmfyouALnbARanEVs2+0fL376saMdVttz/A4x8NulnHdAGajGYtR bmbhHM8ttGyfAsl1k+KHRsTBc4maWOfl+mWYvY3uQUFnyLd1RWCo4dirB8DM20ouxegN Cmfg== 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 g22-20020a1709061e1600b007a641e472f0si12263237ejj.139.2022.11.16.02.59.08; Wed, 16 Nov 2022 02:59:30 -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 S231981AbiKPKJn (ORCPT + 91 others); Wed, 16 Nov 2022 05:09:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbiKPKJm (ORCPT ); Wed, 16 Nov 2022 05:09:42 -0500 Received: from bmailout1.hostsharing.net (bmailout1.hostsharing.net [IPv6:2a01:37:1000::53df:5f64:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8D0F1DDC0; Wed, 16 Nov 2022 02:09:40 -0800 (PST) Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (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 bmailout1.hostsharing.net (Postfix) with ESMTPS id 390A13000BA01; Wed, 16 Nov 2022 11:09:39 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 269184378B; Wed, 16 Nov 2022 11:09:39 +0100 (CET) Date: Wed, 16 Nov 2022 11:09:39 +0100 From: Lukas Wunner To: ira.weiny@intel.com Cc: Dan Williams , Bjorn Helgaas , Bjorn Helgaas , Gregory Price , Jonathan Cameron , Alison Schofield , Vishal Verma , Ben Widawsky , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH] PCI/doe: Fix work struct declaration Message-ID: <20221116100939.GA32050@wunner.de> References: <20221115011943.1051039-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221115011943.1051039-1-ira.weiny@intel.com> 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 On Mon, Nov 14, 2022 at 05:19:43PM -0800, ira.weiny@intel.com wrote: > From: Ira Weiny > > The callers of pci_doe_submit_task() allocate the pci_doe_task on the > stack. This causes the work structure to be allocated on the stack > without pci_doe_submit_task() knowing. Work item initialization needs > to be done with either INIT_WORK_ONSTACK() or INIT_WORK() depending on > how the work item is allocated. > > 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. > > Compromise with an intermediate step to initialize the task struct with > a new call pci_doe_init_task() which must be called prior to submit > task. > > [1] https://lore.kernel.org/linux-cxl/20221014151045.24781-1-Jonathan.Cameron@huawei.com/T/#m88a7f50dcce52f30c8bf5c3dcc06fa9843b54a2d > [2] https://lore.kernel.org/linux-cxl/20221014151045.24781-1-Jonathan.Cameron@huawei.com/T/#m63c636c5135f304480370924f4d03c00357be667 We have object_is_on_stack(), included from . So you could just autosense in pci_doe_submit_task() whether pci_doe_task is on the stack and call the appropriate INIT_WORK variant. Any reason not to do that? Thanks, Lukas