All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] tiny fixes to watch_queue
@ 2021-02-11 22:21 Gabriel Krisman Bertazi
  2021-02-11 22:21 ` [PATCH 1/2] watch_queue: Fold info_id initialization into init_watch Gabriel Krisman Bertazi
  2021-02-11 22:21 ` [PATCH 2/2] docs: watch_queue: Fix unit of the notification size field Gabriel Krisman Bertazi
  0 siblings, 2 replies; 3+ messages in thread
From: Gabriel Krisman Bertazi @ 2021-02-11 22:21 UTC (permalink / raw)
  To: dhowells; +Cc: linux-doc, linux-kernel, Gabriel Krisman Bertazi, kernel

Hi David,

You'll find here a couple of misc improvements to watch_queue
documentation and code.

Gabriel Krisman Bertazi (2):
  watch_queue: Fold info_id initialization into init_watch
  docs: watch_queue: Fix unit of the notification size field

 Documentation/watch_queue.rst | 7 ++++---
 include/linux/watch_queue.h   | 2 +-
 kernel/watch_queue.c          | 5 ++++-
 security/keys/keyctl.c        | 3 +--
 4 files changed, 10 insertions(+), 7 deletions(-)

-- 
2.30.0


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

* [PATCH 1/2] watch_queue: Fold info_id initialization into init_watch
  2021-02-11 22:21 [PATCH 0/2] tiny fixes to watch_queue Gabriel Krisman Bertazi
@ 2021-02-11 22:21 ` Gabriel Krisman Bertazi
  2021-02-11 22:21 ` [PATCH 2/2] docs: watch_queue: Fix unit of the notification size field Gabriel Krisman Bertazi
  1 sibling, 0 replies; 3+ messages in thread
From: Gabriel Krisman Bertazi @ 2021-02-11 22:21 UTC (permalink / raw)
  To: dhowells; +Cc: linux-doc, linux-kernel, Gabriel Krisman Bertazi, kernel

info_id needs to be or'ed when initializing a struct watch.  That's an
internal detail to the watch_queue api, so fold that logic into the
watch_queue implementation, instead of replicating it on multiple
callers.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
---
 Documentation/watch_queue.rst | 5 +++--
 include/linux/watch_queue.h   | 2 +-
 kernel/watch_queue.c          | 5 ++++-
 security/keys/keyctl.c        | 3 +--
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/Documentation/watch_queue.rst b/Documentation/watch_queue.rst
index 54f13ad5fc17..426038e10276 100644
--- a/Documentation/watch_queue.rst
+++ b/Documentation/watch_queue.rst
@@ -170,10 +170,11 @@ different ID are ignored.
 
 The following functions are provided to manage watches:
 
-  * ``void init_watch(struct watch *watch, struct watch_queue *wqueue);``
+  * ``void init_watch(struct watch *watch, struct watch_queue *wqueue, int tag);``
 
     Initialise a watch object, setting its pointer to the watch queue, using
-    appropriate barriering to avoid lockdep complaints.
+    appropriate barriering to avoid lockdep complaints. tag is the user
+    provided value returned in the notification's info_id field.
 
   * ``int add_watch_to_object(struct watch *watch, struct watch_list *wlist);``
 
diff --git a/include/linux/watch_queue.h b/include/linux/watch_queue.h
index 2f5a7446bca6..eec43e43de51 100644
--- a/include/linux/watch_queue.h
+++ b/include/linux/watch_queue.h
@@ -82,7 +82,7 @@ extern void __post_watch_notification(struct watch_list *,
 				      u64, const char*, va_list*);
 extern struct watch_queue *get_watch_queue(int);
 extern void put_watch_queue(struct watch_queue *);
-extern void init_watch(struct watch *, struct watch_queue *);
+extern void init_watch(struct watch *, struct watch_queue *, char);
 extern int add_watch_to_object(struct watch *, struct watch_list *);
 extern int remove_watch_from_object(struct watch_list *, struct watch_queue *, u64, bool);
 extern long watch_queue_set_size(struct pipe_inode_info *, unsigned int);
diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c
index 89fcf0420ce7..55a730278d3f 100644
--- a/kernel/watch_queue.c
+++ b/kernel/watch_queue.c
@@ -435,14 +435,17 @@ static void put_watch(struct watch *watch)
  * init_watch_queue - Initialise a watch
  * @watch: The watch to initialise.
  * @wqueue: The queue to assign.
+ * @tag: The tag identifying this entry in watch_queues
  *
  * Initialise a watch and set the watch queue.
  */
-void init_watch(struct watch *watch, struct watch_queue *wqueue)
+void init_watch(struct watch *watch, struct watch_queue *wqueue, char tag)
 {
 	kref_init(&watch->usage);
 	INIT_HLIST_NODE(&watch->list_node);
 	INIT_HLIST_NODE(&watch->queue_node);
+	watch->info_id = (u32) tag << WATCH_INFO_ID__SHIFT;
+
 	rcu_assign_pointer(watch->queue, wqueue);
 }
 
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 61a614c21b9b..cffabd33d1ca 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -1801,9 +1801,8 @@ long keyctl_watch_key(key_serial_t id, int watch_queue_fd, int watch_id)
 		if (!watch)
 			goto err_wlist;
 
-		init_watch(watch, wqueue);
+		init_watch(watch, wqueue, (char) watch_id);
 		watch->id	= key->serial;
-		watch->info_id	= (u32)watch_id << WATCH_INFO_ID__SHIFT;
 
 		ret = security_watch_key(key);
 		if (ret < 0)
-- 
2.30.0


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

* [PATCH 2/2] docs: watch_queue: Fix unit of the notification size field
  2021-02-11 22:21 [PATCH 0/2] tiny fixes to watch_queue Gabriel Krisman Bertazi
  2021-02-11 22:21 ` [PATCH 1/2] watch_queue: Fold info_id initialization into init_watch Gabriel Krisman Bertazi
@ 2021-02-11 22:21 ` Gabriel Krisman Bertazi
  1 sibling, 0 replies; 3+ messages in thread
From: Gabriel Krisman Bertazi @ 2021-02-11 22:21 UTC (permalink / raw)
  To: dhowells; +Cc: linux-doc, linux-kernel, Gabriel Krisman Bertazi, kernel

Looking at the code and other documentation, the unit of size is
bytes.  Previously, the same documentation says bytes.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
---
 Documentation/watch_queue.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/watch_queue.rst b/Documentation/watch_queue.rst
index 426038e10276..75adb1874a0f 100644
--- a/Documentation/watch_queue.rst
+++ b/Documentation/watch_queue.rst
@@ -215,7 +215,7 @@ the following function should be used::
 
 The notification should be preformatted and a pointer to the header (``n``)
 should be passed in.  The notification may be larger than this and the size in
-units of buffer slots is noted in ``n->info & WATCH_INFO_LENGTH``.
+bytes is noted in ``n->info & WATCH_INFO_LENGTH``.
 
 The ``cred`` struct indicates the credentials of the source (subject) and is
 passed to the LSMs, such as SELinux, to allow or suppress the recording of the
-- 
2.30.0


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

end of thread, other threads:[~2021-02-11 22:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-11 22:21 [PATCH 0/2] tiny fixes to watch_queue Gabriel Krisman Bertazi
2021-02-11 22:21 ` [PATCH 1/2] watch_queue: Fold info_id initialization into init_watch Gabriel Krisman Bertazi
2021-02-11 22:21 ` [PATCH 2/2] docs: watch_queue: Fix unit of the notification size field Gabriel Krisman Bertazi

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.