lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 15 Jan 2015 21:02:37 +0000 (GMT)
From:	Jason Baron <jbaron@...mai.com>
To:	akpm@...ux-foundation.org, famz@...hat.com
Cc:	normalperson@...t.net, nzimmer@....com, viro@...iv.linux.org.uk,
	davidel@...ilserver.org, rostedt@...dmis.org,
	linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: [RFC PATCH 3/5] epoll: add ep_call_nested_nolock()

Add an ep_call_nested_nolock() variant which functions the same as
the current ep_call_nested(), except it does not acquire any locks. This
call wil be used by subsequent patches which have provide their own
'external' locking.

Signed-off-by: Jason Baron <jbaron@...mai.com>
---
 fs/eventpoll.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 2864d67..d0a021a 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -373,11 +373,17 @@ static inline int ep_events_available(struct eventpoll *ep)
 	return !list_empty(&ep->rdllist) || ep->ovflist != EP_UNACTIVE_PTR;
 }
 
+#define ep_call_nested(ncalls, max_nests, nproc, priv, cookie, ctx) \
+	_ep_call_nested(ncalls, max_nests, nproc, priv, cookie, ctx, 1)
+
+#define ep_call_nested_nolock(ncalls, max_nests, nproc, priv, cookie, ctx) \
+	_ep_call_nested(ncalls, max_nests, nproc, priv, cookie, ctx, 0)
+
 /**
- * ep_call_nested - Perform a bound (possibly) nested call, by checking
- *                  that the recursion limit is not exceeded, and that
- *                  the same nested call (by the meaning of same cookie) is
- *                  no re-entered.
+ * _ep_call_nested - Perform a bound (possibly) nested call, by checking
+ *                   that the recursion limit is not exceeded, and that
+ *                   the same nested call (by the meaning of same cookie) is
+ *                   no re-entered.
  *
  * @ncalls: Pointer to the nested_calls structure to be used for this call.
  * @max_nests: Maximum number of allowed nesting calls.
@@ -385,21 +391,23 @@ static inline int ep_events_available(struct eventpoll *ep)
  * @priv: Opaque data to be passed to the @nproc callback.
  * @cookie: Cookie to be used to identify this nested call.
  * @ctx: This instance context.
+ * @lock: protected by the lock or not
  *
  * Returns: Returns the code returned by the @nproc callback, or -1 if
  *          the maximum recursion limit has been exceeded.
  */
-static int ep_call_nested(struct nested_calls *ncalls, int max_nests,
+static int _ep_call_nested(struct nested_calls *ncalls, int max_nests,
 			  int (*nproc)(void *, void *, int), void *priv,
-			  void *cookie, void *ctx)
+			  void *cookie, void *ctx, bool lock)
 {
 	int error, call_nests = 0;
-	unsigned long flags;
+	unsigned long flags = 0;
 	struct list_head *lsthead = &ncalls->tasks_call_list;
 	struct nested_call_node *tncur;
 	struct nested_call_node tnode;
 
-	spin_lock_irqsave(&ncalls->lock, flags);
+	if (lock)
+		spin_lock_irqsave(&ncalls->lock, flags);
 
 	/*
 	 * Try to see if the current task is already inside this wakeup call.
@@ -423,16 +431,19 @@ static int ep_call_nested(struct nested_calls *ncalls, int max_nests,
 	tnode.cookie = cookie;
 	list_add(&tnode.llink, lsthead);
 
-	spin_unlock_irqrestore(&ncalls->lock, flags);
+	if (lock)
+		spin_unlock_irqrestore(&ncalls->lock, flags);
 
 	/* Call the nested function */
 	error = (*nproc)(priv, cookie, call_nests);
 
 	/* Remove the current task from the list */
-	spin_lock_irqsave(&ncalls->lock, flags);
+	if (lock)
+		spin_lock_irqsave(&ncalls->lock, flags);
 	list_del(&tnode.llink);
 out_unlock:
-	spin_unlock_irqrestore(&ncalls->lock, flags);
+	if (lock)
+		spin_unlock_irqrestore(&ncalls->lock, flags);
 
 	return error;
 }
-- 
1.8.2.rc2

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ