Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6498054rwb; Tue, 22 Nov 2022 14:23:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf5eYDpGwaaKY9oYeQ9eSn3iAppCoaj0geeTV+LSuCI7J8qFFQ8BdanMsdr0aeyh5F5kEJ06 X-Received: by 2002:a17:903:2601:b0:189:315f:d6fc with SMTP id jd1-20020a170903260100b00189315fd6fcmr6018927plb.35.1669155837903; Tue, 22 Nov 2022 14:23:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669155837; cv=none; d=google.com; s=arc-20160816; b=FUiu/tcBLPzAdC43d3a0Y450JwAujLASq1B+Ae/yCtJO+nt9T48nv8s64WpzLHct0j 2MoThJ/jmsviUTcE1Mhrn4Gw4NYkTqGtJ7jeJsnJgjO79ZM+P1J4o5q01CFiobxRvwQv B5KlkBfHIN/X5gXzJ+GUzAMyi+oZjKz7whTa8DeTAsH0i36gP7SBmXuKhtQA9ba/h6NW 8rVMbcgMlJcMn6fmWUYTIBzlze+jXJfBZbzAyjDJuZjJ5NLlX479x8cL727bmqAmoN0P dZcqD9rVP8Vdueum373oCbS0En7V2NnAImo3BpVezj62rM5z/1UZuV2oQu2+Od2PPjLa xsAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=CIMrcOp1NM10AM7taVr+UuB838x+RbmQ4KpFG0De028=; b=XBq54zs9c3Nb0Iz6H/TvCNInpf6DDF3UvXfBqlx+T+Br5mmx7f/1ZBMsSXeG0ullxv 4aIcpXeOak8D2mddHaQet2tKCWqj5ZUIrG32tGIUkbg/EKZWrjZjGKm3/dcVL87AGhav an5Wq6wpa+k6cUx7hhXaLbrg9mJQ51IwOV0g/fmY8YUK9z+lOugE6AT+rca0eF7hb91b WUKtsOD1KpCUr3ULVGkyu4kA6ZJmuaUXGsDW/gKAvENGEc8YEhxq7ZKGI/hyqLefCjN3 IY/dXEnJlS6NC5Al75XQ1qfe21HyWUrRWvLAjpd1IU7B/4bXSXr5eNgQeeZZAvmtwbEr 4DPA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v17-20020a056a00149100b0056be3585c3asi15880317pfu.266.2022.11.22.14.23.45; Tue, 22 Nov 2022 14:23:57 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234151AbiKVWGR convert rfc822-to-8bit (ORCPT + 90 others); Tue, 22 Nov 2022 17:06:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234875AbiKVWGM (ORCPT ); Tue, 22 Nov 2022 17:06:12 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 388C56DCC5 for ; Tue, 22 Nov 2022 14:06:08 -0800 (PST) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-254-sgcAsR24PNu03owwWGE96w-1; Tue, 22 Nov 2022 22:06:05 +0000 X-MC-Unique: sgcAsR24PNu03owwWGE96w-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 22 Nov 2022 22:06:04 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.044; Tue, 22 Nov 2022 22:06:04 +0000 From: David Laight To: 'Dan Williams' , Lukas Wunner CC: "'ira.weiny@intel.com'" , Bjorn Helgaas , 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 Thread-Topic: [PATCH V2] PCI/DOE: Detect on stack work items automatically Thread-Index: AQHY+uF8IwLsQKEiakO+LlTXtrnK365EZJiQgAcGD4iAABtQEA== Date: Tue, 22 Nov 2022 22:06:04 +0000 Message-ID: References: <20221118000524.1477383-1-ira.weiny@intel.com> <20221122171309.GA11310@wunner.de> <20221122171406.GC11310@wunner.de> <637d2f98db8b_12cdff29464@dwillia2-xfh.jf.intel.com.notmuch> In-Reply-To: <637d2f98db8b_12cdff29464@dwillia2-xfh.jf.intel.com.notmuch> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,PDS_BAD_THREAD_QP_64, RCVD_IN_DNSWL_NONE,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 From: Dan Williams > Sent: 22 November 2022 20:23 ... > > > > > 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? > > I had this initial reaction as well, but INIT_WORK_ONSTACK() documents > an important detail of the object's lifetime. Here are 2 examples of > functions that would become trickier to read if the kernel did a > global s/INIT_WORK_ONSTACK()/INIT_WORK()/ > > synchronize_rcu_expedited_queue_work() > insert_wq_barrier() > > ...where those take arguments that are known to come from the stack and > be used in async context. I suspect the check was added in response to some code that added on on-stack item and then slept after returning from that function. One option would be to change the diagnostic check to: is_on_stack != !object_is_on_stack(addr) and then pass in 2 so the test always succeeds. But I suspect that won't be liked. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)