Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1023338rwb; Wed, 16 Nov 2022 10:50:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf5z1bXLE4s+CCgjDYrqFY14TNZZo71mZ3ktrZpNB9c9mykNro3qu80UKvMmFW0Lq3reeZ58 X-Received: by 2002:a05:6402:174c:b0:458:ece7:d1f0 with SMTP id v12-20020a056402174c00b00458ece7d1f0mr19947896edx.409.1668624603270; Wed, 16 Nov 2022 10:50:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668624603; cv=none; d=google.com; s=arc-20160816; b=XUXOntliLYmKqh8LLzqcoYhepWImB5kWvhrKQJniAOZAh378PtrBMYyqca+/+snWEI zjDl+tJPIYFOlYc3iUd2FgA9BhnA3LXOJRTCR03NnphuHKex0nEpwQIU/UWQJMkAl5hG Em0fBZAASeWmwf6fW03pydQb2Qyk0xi6nskkVg6s2WFg86hmP5Q3oFi6DLds2O9Y3doN tiWmA49sjTRPG2/qKhtqoP5E3YeZeNcjxwxGCXU/Trqf+35W8sl7611eoa235TYDa3UD qSATI8TqrfAFv4i3b854GcZ5EqdCW+UnaM2JeB+FolQ0hoDrxSOra88bQWh/HI15rYeS EgdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=h5IBvMUZCRkZrpHwJp203fDW+BUBakuoNGRJlx+eQM8=; b=mnxQVkKESdRCyLT1+D8SBPOdTKvNgSgXySFyLjspw0FIYnfFwc2qSuroIrB2mlyhNm 56bHdmlPZfy6fZvLjg98ehAD7+D77jfHo4y3MXQqGOneYrHNAfCgJDqnKk/g1NV4eOeR 2JsOsVnW34F4OLrigyBl+dGBhtg6KBRyfNj0uJvWCdWLchI/wFoN0ZQ0oUUjyaDl/L/u UCePGpA7LSDhnX90UmZOHgLA9R/cWW5I5ggy/XnUow2lpeKApSNd4PNPYB2cEm/rdjAp WzjcJ/5qhzrKq55NHTJsWVkGgYCoK5W46HjncZC/kEcDkXYXgyGxQO/dojXVITqznDz3 ACGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Ww2k/scG"; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i36-20020a0564020f2400b00447d6f244c6si15048246eda.248.2022.11.16.10.49.40; Wed, 16 Nov 2022 10:50:03 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Ww2k/scG"; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238523AbiKPSUs (ORCPT + 90 others); Wed, 16 Nov 2022 13:20:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238721AbiKPSUo (ORCPT ); Wed, 16 Nov 2022 13:20:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CB644299B; Wed, 16 Nov 2022 10:20:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C7627B81DFB; Wed, 16 Nov 2022 18:20:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25648C433C1; Wed, 16 Nov 2022 18:20:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668622839; bh=52xx2cxMjYfYYtzcGVPoVln7tb0sgoWGLZmi9fAr4go=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=Ww2k/scGtapdtys5K2gcUYKS8Vp1Yxq9BnwvvbuwB4F0J1h7DZfFpPW77ePZvuUSv wO1Hx4qGsfRcdrpkRyWN4TUfoAo4/E1eLE5lcE91aC1NSd1RFhIGKZg52bE4Xa/hA6 YcCPc5gWWB6nlJGwxIMUZ8HLuH8ZE76AM5+hl83sPv3XZUbNY8/oLHaW4Ihkk3KsK8 JVrmD5skUyi4qDf/Wa5mTmvLe7cpaP0ADnCLUpFyuxXaNXlsE7wRr/878CNDcrti75 iq+hX28bwPscDMEboURMgvrNW0RAiqZwsmgAyslR06o9YcZum0qcTh3XBlcitncW6+ 6L+cEj03x788g== Date: Wed, 16 Nov 2022 12:20:37 -0600 From: Bjorn Helgaas To: Lukas Wunner Cc: ira.weiny@intel.com, Dan Williams , 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: <20221116182037.GA1127308@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221116100939.GA32050@wunner.de> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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, Nov 16, 2022 at 11:09:39AM +0100, Lukas Wunner wrote: > 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. Nifty, I had no idea object_is_on_stack() existed, thank you! I wonder if there's an opportunity to use object_is_on_stack() somewhere in the INIT_WORK() path to find usage mistakes. Adding it in pci_doe_submit_task() would add some complexity, so I'm not sure whether it's worth adding it unless we actually have uses for both cases. Bjorn