Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1262192 > unrolled thread

Re: [PATCH v3 1/4] wait.[ch]: Introduce the simple waitqueue (swait) implementation

Started byThomas Gleixner <tglx@linutronix.de>
First post2015-11-04 11:40 +0100
Last post2015-11-04 13:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v3 1/4] wait.[ch]: Introduce the simple waitqueue (swait)  implementation Thomas Gleixner <tglx@linutronix.de> - 2015-11-04 11:40 +0100
    Re: [PATCH v3 1/4] wait.[ch]: Introduce the simple waitqueue (swait)  implementation Daniel Wagner <daniel.wagner@bmw-carit.de> - 2015-11-04 13:20 +0100

#1262192 — Re: [PATCH v3 1/4] wait.[ch]: Introduce the simple waitqueue (swait) implementation

FromThomas Gleixner <tglx@linutronix.de>
Date2015-11-04 11:40 +0100
SubjectRe: [PATCH v3 1/4] wait.[ch]: Introduce the simple waitqueue (swait) implementation
Message-ID<qr3DX-7Fs-5@gated-at.bofh.it>
On Tue, 20 Oct 2015, Daniel Wagner wrote:
> +
> +extern void swake_up(struct swait_queue_head *q);
> +extern void swake_up_all(struct swait_queue_head *q);
> +extern void swake_up_locked(struct swait_queue_head *q);

I intentionally named these functions swait_wake* in my initial
implementation for two reasons:

  - typoing wake_up vs. swake_up only emits a compiler warning and does
    not break the build
    
  - I really prefer new infrastructure to have a consistent prefix
    which reflects the "subsystem". That's simpler to read and simpler
    to grep for.

> +extern void __prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait);
> +extern void prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait, int state);
> +extern long prepare_to_swait_event(struct swait_queue_head *q, struct swait_queue *wait, int state);
> +
> +extern void __finish_swait(struct swait_queue_head *q, struct swait_queue *wait);
> +extern void finish_swait(struct swait_queue_head *q, struct swait_queue *wait);

Can we please go with the original names?

swait_prepare()
swait_prepare_locked()
swait_finish()
swait_finish_locked()

Hmm?

> +#define swait_event(wq, condition)					\

Here we have the same swait vs. wait problem as above. So either we
come up with a slightly different name or have an explicit type check
in __swait_event event.

Thanks,

	tglx


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1262242

FromDaniel Wagner <daniel.wagner@bmw-carit.de>
Date2015-11-04 13:20 +0100
Message-ID<qr5cJ-j6-1@gated-at.bofh.it>
In reply to#1262192
On 11/04/2015 11:33 AM, Thomas Gleixner wrote:
> On Tue, 20 Oct 2015, Daniel Wagner wrote:
>> +
>> +extern void swake_up(struct swait_queue_head *q);
>> +extern void swake_up_all(struct swait_queue_head *q);
>> +extern void swake_up_locked(struct swait_queue_head *q);
> 
> I intentionally named these functions swait_wake* in my initial
> implementation for two reasons:
> 
>   - typoing wake_up vs. swake_up only emits a compiler warning and does
>     not break the build

I played a bit around on this and came up with the patch below. The type
check results in an error.
    
>   - I really prefer new infrastructure to have a consistent prefix
>     which reflects the "subsystem". That's simpler to read and simpler
>     to grep for.
> 
>> +extern void __prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait);
>> +extern void prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait, int state);
>> +extern long prepare_to_swait_event(struct swait_queue_head *q, struct swait_queue *wait, int state);
>> +
>> +extern void __finish_swait(struct swait_queue_head *q, struct swait_queue *wait);
>> +extern void finish_swait(struct swait_queue_head *q, struct swait_queue *wait);
> 
> Can we please go with the original names?
> 
> swait_prepare()
> swait_prepare_locked()
> swait_finish()
> swait_finish_locked()
> 
> Hmm?

I defer to Peter :)

>> +#define swait_event(wq, condition)					\
> 
> Here we have the same swait vs. wait problem as above. So either we
> come up with a slightly different name or have an explicit type check
> in __swait_event event.

What about something like this:

diff --git a/include/linux/swait.h b/include/linux/swait.h
index c1f9c62..f59369d 100644
--- a/include/linux/swait.h
+++ b/include/linux/swait.h
@@ -6,6 +6,9 @@
 #include <linux/spinlock.h>
 #include <asm/current.h>
 
+#define compiletime_assert_same_type(a, b) \
+       compiletime_assert(__same_type(a, b), "Need to match correct type");
+
 /*
  * Simple wait queues
  *
@@ -66,6 +69,7 @@ extern void __init_swait_queue_head(struct swait_queue_head *q, const char *name
 #define init_swait_queue_head(q)                               \
        do {                                                    \
                static struct lock_class_key __key;             \
+               compiletime_assert_same_type(struct swait_queue_head *, q); \
                __init_swait_queue_head((q), #q, &__key);       \
        } while (0)
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web