All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Lyude Paul <lyude@redhat.com>
Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, "Daniel Vetter" <daniel@ffwll.ch>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Petr Mladek" <pmladek@suse.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Liang Chen" <cl@rock-chips.com>,
	"Ben Dooks" <ben.dooks@codethink.co.uk>,
	"Thomas Gleixner" <tglx@linutronix.de>
Subject: Re: [RFC v4 02/12] kthread: Add kthread_(un)block_work_queuing() and kthread_work_queuable()
Date: Mon, 11 May 2020 11:02:51 -0400	[thread overview]
Message-ID: <20200511150251.GE16815@mtj.duckdns.org> (raw)
In-Reply-To: <20200508204751.155488-3-lyude@redhat.com>

On Fri, May 08, 2020 at 04:46:52PM -0400, Lyude Paul wrote:
> Add some simple wrappers around incrementing/decrementing
> kthread_work.cancelling under lock, along with checking whether queuing
> is currently allowed on a given kthread_work, which we'll use want to
> implement work cancelling with DRM's vblank work helpers.

Am I correct in assuming that what you want is "cancel this and block
further queueing until the state is cleared"? I agree that'd be something
really useful to have. That said, There are a few areas that I think can be
improved upon:

* It'd be better if we separate this state into its own thing rather than
  mixing with canceling state which has potential to make things really
  confusing. It doesn't have to be a separate field unless you want disable
  depth for work item disable (and I don't think you do). It can just be a
  high bit in the same field but I think the two states should be separate
  one way or the other.

* I'm always a bit skeptical about state querying interfaces which aren't
  synchronized to anything. They're useful in many cases but also prone to
  being misused. If you absoultely have to have them, can you please add
  explicit comment explaining the lack of synchronization around it - ie.
  unless you're the one setting and clearing the flag and queueing the task,
  it isn't synchronized against anything.

* In the same vein, I'm not too sure about stand-alone block interface.
  Unless I'm the sole queuer or there are further locking around queueing,
  what good does setting blocking do? There's no way to guarantee that the
  flag is seen by someone else trying to queue it and trying to flush the
  work item after queueing doesn't help either. The only way to make that
  interface meaningful is doing it together with cancel - so, you say "block
  further queueing and cancel / flush whatever is in flight or queued",
  which actually gives you a useful invariant.

* A simliar argument can be made about unblock too although that's an a lot
  more relaxed situation in that unblocking and queueing oneself always
  works and that the user might not care which future instance of queueing
  will start succeeding.

Thanks.

-- 
tejun

WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: Lyude Paul <lyude@redhat.com>
Cc: Petr Mladek <pmladek@suse.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org,
	Ben Dooks <ben.dooks@codethink.co.uk>,
	Liang Chen <cl@rock-chips.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [RFC v4 02/12] kthread: Add kthread_(un)block_work_queuing() and kthread_work_queuable()
Date: Mon, 11 May 2020 11:02:51 -0400	[thread overview]
Message-ID: <20200511150251.GE16815@mtj.duckdns.org> (raw)
In-Reply-To: <20200508204751.155488-3-lyude@redhat.com>

On Fri, May 08, 2020 at 04:46:52PM -0400, Lyude Paul wrote:
> Add some simple wrappers around incrementing/decrementing
> kthread_work.cancelling under lock, along with checking whether queuing
> is currently allowed on a given kthread_work, which we'll use want to
> implement work cancelling with DRM's vblank work helpers.

Am I correct in assuming that what you want is "cancel this and block
further queueing until the state is cleared"? I agree that'd be something
really useful to have. That said, There are a few areas that I think can be
improved upon:

* It'd be better if we separate this state into its own thing rather than
  mixing with canceling state which has potential to make things really
  confusing. It doesn't have to be a separate field unless you want disable
  depth for work item disable (and I don't think you do). It can just be a
  high bit in the same field but I think the two states should be separate
  one way or the other.

* I'm always a bit skeptical about state querying interfaces which aren't
  synchronized to anything. They're useful in many cases but also prone to
  being misused. If you absoultely have to have them, can you please add
  explicit comment explaining the lack of synchronization around it - ie.
  unless you're the one setting and clearing the flag and queueing the task,
  it isn't synchronized against anything.

* In the same vein, I'm not too sure about stand-alone block interface.
  Unless I'm the sole queuer or there are further locking around queueing,
  what good does setting blocking do? There's no way to guarantee that the
  flag is seen by someone else trying to queue it and trying to flush the
  work item after queueing doesn't help either. The only way to make that
  interface meaningful is doing it together with cancel - so, you say "block
  further queueing and cancel / flush whatever is in flight or queued",
  which actually gives you a useful invariant.

* A simliar argument can be made about unblock too although that's an a lot
  more relaxed situation in that unblocking and queueing oneself always
  works and that the user might not care which future instance of queueing
  will start succeeding.

Thanks.

-- 
tejun
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-05-11 15:02 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08 20:46 [RFC v4 00/12] drm/nouveau: Introduce CRC support for gf119+ Lyude Paul
2020-05-08 20:46 ` Lyude Paul
2020-05-08 20:46 ` Lyude Paul
2020-05-08 20:46 ` [RFC v4 01/12] kthread: Add kthread_queue_flush_work() Lyude Paul
2020-05-08 20:46   ` Lyude Paul
2020-05-09 16:31   ` kbuild test robot
2020-05-11 14:49   ` Tejun Heo
2020-05-11 14:49     ` Tejun Heo
2020-05-11 15:02     ` Daniel Vetter
2020-05-11 15:02       ` Daniel Vetter
2020-05-08 20:46 ` [RFC v4 02/12] kthread: Add kthread_(un)block_work_queuing() and kthread_work_queuable() Lyude Paul
2020-05-08 20:46   ` Lyude Paul
2020-05-11 15:02   ` Tejun Heo [this message]
2020-05-11 15:02     ` Tejun Heo
     [not found]   ` <20200508204751.155488-3-lyude-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2020-05-14 15:07     ` William Lewis
2020-05-08 20:46 ` [RFC v4 03/12] drm/vblank: Register drmm cleanup action once per drm_vblank_crtc Lyude Paul
2020-05-08 20:46   ` Lyude Paul
2020-05-08 20:59   ` Daniel Vetter
2020-05-08 20:59     ` Daniel Vetter
2020-05-08 20:46 ` [RFC v4 04/12] drm/vblank: Add vblank works Lyude Paul
2020-05-08 20:46   ` Lyude Paul
2020-05-10  3:03   ` kbuild test robot
2020-05-12 17:56     ` Nick Desaulniers
2020-05-08 20:46 ` [RFC v4 05/12] drm/nouveau/kms/nv50-: Unroll error cleanup in nv50_head_create() Lyude Paul
2020-05-08 20:46   ` Lyude Paul
2020-05-08 20:46   ` Lyude Paul
2020-05-08 20:46 ` [RFC v4 06/12] drm/nouveau/kms/nv140-: Don't modify depth in state during atomic commit Lyude Paul
2020-05-08 20:46   ` Lyude Paul
2020-05-08 20:46 ` [RFC v4 07/12] drm/nouveau/kms/nv50-: Fix disabling dithering Lyude Paul
2020-05-08 20:46   ` Lyude Paul
2020-05-08 20:46 ` [RFC v4 08/12] drm/nouveau/kms/nv50-: s/harm/armh/g Lyude Paul
2020-05-08 20:46   ` Lyude Paul
2020-05-08 20:46 ` [RFC v4 09/12] drm/nouveau/kms/nv140-: Track wndw mappings in nv50_head_atom Lyude Paul
2020-05-08 20:46   ` Lyude Paul
2020-05-08 20:46   ` Lyude Paul
2020-05-08 20:47 ` [RFC v4 10/12] drm/nouveau/kms/nv50-: Expose nv50_outp_atom in disp.h Lyude Paul
2020-05-08 20:47   ` Lyude Paul
2020-05-08 20:47   ` Lyude Paul
2020-05-08 20:47 ` [RFC v4 11/12] drm/nouveau/kms/nv50-: Move hard-coded object handles into header Lyude Paul
2020-05-08 20:47   ` Lyude Paul
2020-05-08 20:47 ` [RFC v4 12/12] drm/nouveau/kms/nvd9-: Add CRC support Lyude Paul
2020-05-08 20:47   ` Lyude Paul
2020-05-08 20:47   ` Lyude Paul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200511150251.GE16815@mtj.duckdns.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=ben.dooks@codethink.co.uk \
    --cc=cl@rock-chips.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lyude@redhat.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=pmladek@suse.com \
    --cc=surenb@google.com \
    --cc=tglx@linutronix.de \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.