All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 12/37] drm/i915: Add fetch_and_zero() macro
Date: Fri, 12 Aug 2016 09:05:32 +0100	[thread overview]
Message-ID: <20160812080532.GS12148@nuc-i3427.alporthouse.com> (raw)
In-Reply-To: <1470988546.3709.7.camel@linux.intel.com>

On Fri, Aug 12, 2016 at 10:55:46AM +0300, Joonas Lahtinen wrote:
> On pe, 2016-08-12 at 07:54 +0100, Chris Wilson wrote:
> > A simple little macro to clear a pointer and return the old value. This
> > is useful for writing
> > 
> > 	value = *ptr;
> > 	if (!value)
> > 		return;
> > 
> > 	*ptr = 0;
> > 	...
> > 	free(value);
> > 
> > in a slightly more concise form:
> > 
> > 	value = fetch_and_zero(ptr);
> > 	if (!value)
> > 		return;
> > 
> > 	...
> > 	free(value);
> > 
> > with the idea that this establishes a pattern that may be extended for
> > atomic use (using xchg or cmpxchg) i.e. atomic_fetch_and_zero() and
> > similar to llist.
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > ---
> >  drivers/gpu/drm/i915/i915_drv.h | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> > index a4203ff0cf7f..731c67fc9796 100644
> > --- a/drivers/gpu/drm/i915/i915_drv.h
> > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > @@ -3903,4 +3903,10 @@ static inline bool __i915_request_irq_complete(struct drm_i915_gem_request *req)
> >  	return false;
> >  }
> >  
> > +#define fetch_and_zero(ptr) ({					\
> > +	typeof(*ptr) T__ = *(ptr);					\
> 
> Looking at container_of etc. it's always __ as prefix.

The advice to use the suffix is from gcc's manual iirc, and there are a
few macros that do dotted around the place, but it looks overwhelmingly
in favour of the prefix.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-08-12  8:05 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-12  6:53 [PATCH 01/37] drm/i915: Record the position of the start of the request Chris Wilson
2016-08-12  6:53 ` [PATCH 02/37] drm/i915: Reduce amount of duplicate buffer information captured on error Chris Wilson
2016-08-12  6:53 ` [PATCH 03/37] drm/i915: Stop the machine whilst capturing the GPU crash dump Chris Wilson
2016-08-12  6:53 ` [PATCH 04/37] drm/i915: Store the active context object on all engines upon error Chris Wilson
2016-08-12  6:53 ` [PATCH 05/37] drm/i915: Remove inactive/active list from debugfs Chris Wilson
2016-08-12  6:53 ` [PATCH 06/37] drm/i915: Focus debugfs/i915_gem_pinned to show only display pins Chris Wilson
2016-08-12  6:53 ` [PATCH 07/37] drm/i915: Reduce i915_gem_objects to only show object information Chris Wilson
2016-08-12  7:21   ` Joonas Lahtinen
2016-08-12  6:53 ` [PATCH 08/37] drm/i915: Record the device capabilities at the time of a hang Chris Wilson
2016-08-12  7:42   ` Joonas Lahtinen
2016-08-12  6:53 ` [PATCH 09/37] drm/i915: Remove redundant WARN_ON from __i915_add_request() Chris Wilson
2016-08-12  6:54 ` [PATCH 10/37] drm/i915: Always set the vma->pages Chris Wilson
2016-08-12  7:48   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 11/37] drm/i915: Create a VMA for an object Chris Wilson
2016-08-12  6:54 ` [PATCH 12/37] drm/i915: Add fetch_and_zero() macro Chris Wilson
2016-08-12  7:55   ` Joonas Lahtinen
2016-08-12  8:05     ` Chris Wilson [this message]
2016-08-12  6:54 ` [PATCH 13/37] drm/i915: Add convenience wrappers for vma's object get/put Chris Wilson
2016-08-12  8:03   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 14/37] drm/i915: Track pinned vma inside guc Chris Wilson
2016-08-12  9:42   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 15/37] drm/i915: Convert fence computations to use vma directly Chris Wilson
2016-08-12  6:54 ` [PATCH 16/37] drm/i915: Use VMA directly for checking tiling parameters Chris Wilson
2016-08-12  8:16   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 17/37] drm/i915: Use VMA as the primary object for context state Chris Wilson
2016-08-12  6:54 ` [PATCH 18/37] drm/i915: Only clflush the context object when binding Chris Wilson
2016-08-12  8:19   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 19/37] drm/i915: Move assertion for iomap access to i915_vma_pin_iomap Chris Wilson
2016-08-12  8:21   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 20/37] drm/i915: Use VMA for ringbuffer tracking Chris Wilson
2016-08-12  8:34   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 21/37] drm/i915: Use VMA for scratch page tracking Chris Wilson
2016-08-12  6:54 ` [PATCH 22/37] drm/i915: Move common scratch allocation/destroy to intel_engine_cs.c Chris Wilson
2016-08-12  8:40   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 23/37] drm/i915: Move common seqno reset " Chris Wilson
2016-08-12  8:42   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 24/37] drm/i915/overlay: Use VMA as the primary tracker for images Chris Wilson
2016-08-12  6:54 ` [PATCH 25/37] drm/i915: Use VMA as the primary tracker for semaphore page Chris Wilson
2016-08-12  6:54 ` [PATCH 26/37] drm/i915: Use VMA for render state page tracking Chris Wilson
2016-08-12  6:54 ` [PATCH 27/37] drm/i915: Use VMA for wa_ctx tracking Chris Wilson
2016-08-12  6:54 ` [PATCH 28/37] drm/i915: Consolidate i915_vma_unpin_and_release() Chris Wilson
2016-08-12  8:45   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 29/37] drm/i915: Track pinned VMA Chris Wilson
2016-08-12  8:53   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 30/37] drm/i915: Introduce i915_ggtt_offset() Chris Wilson
2016-08-12  9:01   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 31/37] drm/i915: Print the batchbuffer offset next to BBADDR in error state Chris Wilson
2016-08-12  6:54 ` [PATCH 32/37] drm/i915: Move debug only per-request pid tracking from request to ctx Chris Wilson
2016-08-12  9:03   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 33/37] drm/i915: Only record active and pending requests upon a GPU hang Chris Wilson
2016-08-12 12:39   ` Matthew Auld
2016-08-12 12:49     ` Chris Wilson
2016-08-12  6:54 ` [PATCH 34/37] drm/i915: Record the RING_MODE register for post-mortem debugging Chris Wilson
2016-08-12  9:07   ` Joonas Lahtinen
2016-08-12  6:54 ` [PATCH 35/37] drm/i915: Always use the GTT for error capture Chris Wilson
2016-08-12  6:54 ` [PATCH 36/37] drm/i915: Consolidate error object printing Chris Wilson
2016-08-12  6:54 ` [PATCH 37/37] drm/i915: Compress GPU objects in error state Chris Wilson
2016-08-12  7:27 ` ✗ Ro.CI.BAT: failure for series starting with [01/37] drm/i915: Record the position of the start of the request Patchwork
2016-08-12  9:45 ` [PATCH 01/37] " Joonas Lahtinen

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=20160812080532.GS12148@nuc-i3427.alporthouse.com \
    --to=chris@chris-wilson.co.uk \
    --cc=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=joonas.lahtinen@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.