lkml.org 
[lkml]   [2022]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] PCI/doe: Fix work struct declaration
On Mon, Nov 14, 2022 at 05:19:43PM -0800, ira.weiny@intel.com wrote:
> From: Ira Weiny <ira.weiny@intel.com>
>
> 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 <linux/sched/task_stack.h>.

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

\
 
 \ /
  Last update: 2022-11-16 11:10    [W:0.073 / U:0.976 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site