mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] lib/ida: Document locking requirements a bit better v2
@ 2016-10-27  7:22 Daniel Vetter
  2016-10-27 14:21 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Vetter @ 2016-10-27  7:22 UTC (permalink / raw)
  To: LKML
  Cc: Intel Graphics Development, Daniel Vetter, Mel Gorman,
	Michal Hocko, Vlastimil Babka, Tejun Heo, Andrew Morton,
	Daniel Vetter

I wanted to wrap a bunch of ida_simple_get calls into their own
locking, until I dug around and read the original commit message.
Stuff like this should imo be added to the kernel doc, let's do that.

v2: Improve the kerneldoc per Tejun's review.

Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 lib/idr.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lib/idr.c b/lib/idr.c
index 6098336df267..52d2979a05e8 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -927,6 +927,9 @@ EXPORT_SYMBOL(ida_pre_get);
  * and go back to the ida_pre_get() call.  If the ida is full, it will
  * return %-ENOSPC.
  *
+ * Note that callers must ensure that concurrent access to @ida is not possible.
+ * See ida_simple_get() for a varaint which takes care of locking.
+ *
  * @p_id returns a value in the range @starting_id ... %0x7fffffff.
  */
 int ida_get_new_above(struct ida *ida, int starting_id, int *p_id)
@@ -1073,6 +1076,9 @@ EXPORT_SYMBOL(ida_destroy);
  * Allocates an id in the range start <= id < end, or returns -ENOSPC.
  * On memory allocation failure, returns -ENOMEM.
  *
+ * Compared to ida_get_new_above() this function does its own locking, and
+ * should be used unless there are special requirements.
+ *
  * Use ida_simple_remove() to get rid of an id.
  */
 int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end,
@@ -1119,6 +1125,11 @@ EXPORT_SYMBOL(ida_simple_get);
  * ida_simple_remove - remove an allocated id.
  * @ida: the (initialized) ida.
  * @id: the id returned by ida_simple_get.
+ *
+ * Use to release an id allocated with ida_simple_get().
+ *
+ * Compared to ida_remove() this function does its own locking, and should be
+ * used unless there are special requirements.
  */
 void ida_simple_remove(struct ida *ida, unsigned int id)
 {
-- 
2.10.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] lib/ida: Document locking requirements a bit better v2
  2016-10-27  7:22 [PATCH] lib/ida: Document locking requirements a bit better v2 Daniel Vetter
@ 2016-10-27 14:21 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2016-10-27 14:21 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: LKML, Intel Graphics Development, Mel Gorman, Michal Hocko,
	Vlastimil Babka, Andrew Morton, Daniel Vetter

On Thu, Oct 27, 2016 at 09:22:16AM +0200, Daniel Vetter wrote:
> I wanted to wrap a bunch of ida_simple_get calls into their own
> locking, until I dug around and read the original commit message.
> Stuff like this should imo be added to the kernel doc, let's do that.
> 
> v2: Improve the kerneldoc per Tejun's review.
> 
> Cc: Mel Gorman <mgorman@techsingularity.net>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Acked-by: Tejun Heo <tj@kernel.org>

Andrew, can you please route this patch?

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-10-27 14:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27  7:22 [PATCH] lib/ida: Document locking requirements a bit better v2 Daniel Vetter
2016-10-27 14:21 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome