Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1934541ybk; Mon, 11 May 2020 07:54:04 -0700 (PDT) X-Google-Smtp-Source: APiQypJeUdhJ4cYcf5b3Mk0Ttb0LcS0MbRNtbWyuaiMtqbJ7l5xTtbXNmRYVBcNP5hu2EPFeJ8g9 X-Received: by 2002:a17:906:b28a:: with SMTP id q10mr14175721ejz.273.1589208844248; Mon, 11 May 2020 07:54:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589208844; cv=none; d=google.com; s=arc-20160816; b=TcpvN4UQFOIXcs8tGVir4cAdf7gdc2+NRKB1EfzRmWZQSaaCDr2Dqm/uvwTAArSqbZ rdh+4TG9hROhgxGwgScl/tHqml5dr0J87wGY5VyJyPHyUEse2YGv2hFvPvG+euHLj0+z e3WjmwQ5dW+vv4xfeyTpwaeGlR2BKPWn1Cqug5W0SYE2D1yEPO69Ay6GKbcFEdPcNg7B BvH5qHmeZnZx8snJofdbmWAPhf21Scb7iDOYxgB3h7dPEWaXf/Mhq+29E1NdvSDGhBjQ bkxIQ1lUkYON5s17uvVvtk5QAF7HOySutysf+wgVycrlZfXphQvLPCQCqd/zaRluUah0 QoOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=gkrV0mSw419OC87OxKvOah2CgTI8JgcXYdLtKZtu+jI=; b=PUORTdRuW30B7jcc/OpVSR9s9+ZG+OVsbsB4xZ121R3fzinm5veMzyo538vCyBJ3DJ jBPYAt+G4I5ax5cdQ6+qlmZcs7IzGa5FD3ux4vNA53u0OihRgm4CTYwuukBjQXYlf40o tY5PpCzmMGhJLfi4++gYgcNa78vzZKSKZCJ078idGL0pvykyT5Iqfm1pqWakwL1A8Juj YxxWwSBDoWbbftQTpKrEdj67jdBt8h87ZgF1oVMHusSngCTN/Ry6SjkYA6PLUmtwr0KJ Hh9G/XxWIEXN88+yxopw9XqJr40LHqLY5TXkrJtA36us3xRu+KIi/ObydzLhS/845UuK wBmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=IZbkwj0d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id by15si996279edb.259.2020.05.11.07.53.40; Mon, 11 May 2020 07:54:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=IZbkwj0d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730418AbgEKOtj (ORCPT + 99 others); Mon, 11 May 2020 10:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729463AbgEKOti (ORCPT ); Mon, 11 May 2020 10:49:38 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2992C061A0C for ; Mon, 11 May 2020 07:49:38 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id b6so8863214qkh.11 for ; Mon, 11 May 2020 07:49:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=gkrV0mSw419OC87OxKvOah2CgTI8JgcXYdLtKZtu+jI=; b=IZbkwj0dnYrfFciYxfmYFQ5udCQAC5qHRAPV9NNl0BoWruyERrJx3TquhZmI4vKroe bTPMv9wD6vIj8W55dt+aqU/X8/3frl3lNqZxFJjTsjkVU63G/mpVcOYbRJAsG6ftrYR8 g/xpUNmnUFiFuwoNOEQtHFdIb/8b+UbRe7YsoKYIWSukk8twD4NgDyYEwFhtVIgvlpIT JqSCVJ6wok5wz5QnxN7pTC60Af6N0jD3c84DQp43B6zVkh40aBT5/whHXGLxQhb6XVWJ 9Ddi8+64W/Wd1WjaALSO49zCtcKtaU7YziO8rguwnAY9T8WRNPQcYTbCQW2+e6ZEkYUD GK+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=gkrV0mSw419OC87OxKvOah2CgTI8JgcXYdLtKZtu+jI=; b=e/X6uQZgj/wxUklzigFw6wi6MUklu1uH3bW4u/O3ULsnnCr96OUhWWJ14MAwFMstJY I2+R91ndOQnpBt7sznFEZ+rtb4e6AgBN4h2eoihZhM34QTuzeWgL1YqkziLrpTA5vC/t CpCLCxrkyMFCA28KvO4DdyG6z4xau3Y4dB+ZKlZdVA5hicF1klbnc8PFjq3JxcP3ffZI WqsFeyk3EOnTeIlH1yfL4NEAvicZe16B7UD7FDCcnfAeUjGVtPS9LqCCeLmWYuO+5WXo zdsGyYy4XPhU4NzHWLYwkwBMOzXqVd808rpxjcLztY1O9i+CZLFB44/u35wBGI8oPYC+ 7/7g== X-Gm-Message-State: AGi0PuaHEXyr+uISmrb2xXnT198+PkpEHZffDYSMUSD2t/cS1Vkz/xR8 Nuslu6LG89F6ZizAgObHHdg= X-Received: by 2002:a37:8302:: with SMTP id f2mr15691637qkd.220.1589208577620; Mon, 11 May 2020 07:49:37 -0700 (PDT) Received: from localhost ([199.96.181.106]) by smtp.gmail.com with ESMTPSA id b198sm7594350qkg.37.2020.05.11.07.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2020 07:49:37 -0700 (PDT) Date: Mon, 11 May 2020 10:49:35 -0400 From: Tejun Heo To: Lyude Paul Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Daniel Vetter , Ville =?iso-8859-1?Q?Syrj=E4l=E4?= , Andrew Morton , Suren Baghdasaryan , Petr Mladek , Greg Kroah-Hartman , "Steven Rostedt (VMware)" , Thomas Gleixner , Ben Dooks , Liang Chen Subject: Re: [RFC v4 01/12] kthread: Add kthread_queue_flush_work() Message-ID: <20200511144935.GD16815@mtj.duckdns.org> References: <20200508204751.155488-1-lyude@redhat.com> <20200508204751.155488-2-lyude@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200508204751.155488-2-lyude@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Fri, May 08, 2020 at 04:46:51PM -0400, Lyude Paul wrote: > +bool kthread_queue_flush_work(struct kthread_work *work, > + struct kthread_flush_work *fwork); > +void __kthread_flush_work_fn(struct kthread_work *work); As an exposed interface, this doesn't seem great. What the user wants to say is "wait for the current instance of this guy" and the interface is asking them to queue an extra work item whose queueing return state should be checked and depending on that result wait on its internal completion. I'm skeptical this is a good idea in general given that unless you define "this instance" at the time of queueing the work item which is being waited-upon, there's no way to guarantee that the instance you're queueing the flush work item on is the instance you want unless the queuer is holding external synchronization which prevents the instance from running. That's a really confusing semantics to expose in the interface. What the above means is that the ordering that you want is only defined through your own locking and that maybe suggests that the sequencing should be implemented on that side too. It may be a bit more code but a sequence counter + wait queue might be the better solution here. Thanks. -- tejun