From: Waiman Long <longman@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
selinux@vger.kernel.org, Paul Moore <paul@paul-moore.com>,
Stephen Smalley <sds@tycho.nsa.gov>,
Eric Paris <eparis@parisplace.org>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Oleg Nesterov <oleg@redhat.com>, Waiman Long <longman@redhat.com>
Subject: [PATCH 3/4] signal: Add free_uid_to_q()
Date: Thu, 21 Mar 2019 17:45:11 -0400 [thread overview]
Message-ID: <20190321214512.11524-4-longman@redhat.com> (raw)
In-Reply-To: <20190321214512.11524-1-longman@redhat.com>
Add a new free_uid_to_q() function to put the user structure on
freeing queue instead of freeing it directly. That new function is then
called from __sigqueue_free() with a free_q parameter.
Signed-off-by: Waiman Long <longman@redhat.com>
---
include/linux/sched/user.h | 3 +++
kernel/signal.c | 2 +-
kernel/user.c | 17 +++++++++++++----
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/include/linux/sched/user.h b/include/linux/sched/user.h
index c7b5f86b91a1..77f28d5cb940 100644
--- a/include/linux/sched/user.h
+++ b/include/linux/sched/user.h
@@ -63,6 +63,9 @@ static inline struct user_struct *get_uid(struct user_struct *u)
refcount_inc(&u->__count);
return u;
}
+
+struct kmem_free_q_head;
extern void free_uid(struct user_struct *);
+extern void free_uid_to_q(struct user_struct *u, struct kmem_free_q_head *q);
#endif /* _LINUX_SCHED_USER_H */
diff --git a/kernel/signal.c b/kernel/signal.c
index 04fb202c16bd..2ecb23b540eb 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -440,7 +440,7 @@ static void __sigqueue_free(struct sigqueue *q, struct kmem_free_q_head *free_q)
if (q->flags & SIGQUEUE_PREALLOC)
return;
atomic_dec(&q->user->sigpending);
- free_uid(q->user);
+ free_uid_to_q(q->user, free_q);
if (free_q)
kmem_free_q_add(free_q, sigqueue_cachep, q);
else
diff --git a/kernel/user.c b/kernel/user.c
index 0df9b1640b2a..d92629bae546 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -135,14 +135,18 @@ static struct user_struct *uid_hash_find(kuid_t uid, struct hlist_head *hashent)
* IRQ state (as stored in flags) is restored and uidhash_lock released
* upon function exit.
*/
-static void free_user(struct user_struct *up, unsigned long flags)
+static void free_user(struct user_struct *up, unsigned long flags,
+ struct kmem_free_q_head *free_q)
__releases(&uidhash_lock)
{
uid_hash_remove(up);
spin_unlock_irqrestore(&uidhash_lock, flags);
key_put(up->uid_keyring);
key_put(up->session_keyring);
- kmem_cache_free(uid_cachep, up);
+ if (free_q)
+ kmem_free_q_add(free_q, uid_cachep, up);
+ else
+ kmem_cache_free(uid_cachep, up);
}
/*
@@ -162,7 +166,7 @@ struct user_struct *find_user(kuid_t uid)
return ret;
}
-void free_uid(struct user_struct *up)
+void free_uid_to_q(struct user_struct *up, struct kmem_free_q_head *free_q)
{
unsigned long flags;
@@ -170,7 +174,12 @@ void free_uid(struct user_struct *up)
return;
if (refcount_dec_and_lock_irqsave(&up->__count, &uidhash_lock, &flags))
- free_user(up, flags);
+ free_user(up, flags, free_q);
+}
+
+void free_uid(struct user_struct *up)
+{
+ free_uid_to_q(up, NULL);
}
struct user_struct *alloc_uid(kuid_t uid)
--
2.18.1
next prev parent reply other threads:[~2019-03-21 21:45 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-21 21:45 [PATCH 0/4] Signal: Fix hard lockup problem in flush_sigqueue() Waiman Long
2019-03-21 21:45 ` [PATCH 1/4] mm: Implement kmem objects freeing queue Waiman Long
2019-03-22 17:47 ` Christopher Lameter
2019-03-21 21:45 ` [PATCH 2/4] signal: Make flush_sigqueue() use free_q to release memory Waiman Long
2019-03-22 1:52 ` Matthew Wilcox
2019-03-22 11:16 ` Oleg Nesterov
2019-03-22 16:10 ` Waiman Long
2019-03-22 17:50 ` Christopher Lameter
2019-03-22 18:12 ` Waiman Long
2019-03-22 19:39 ` Christopher Lameter
2019-03-22 19:59 ` Matthew Wilcox
2019-03-25 14:15 ` Christopher Lameter
2019-03-25 15:26 ` Matthew Wilcox
2019-03-25 16:16 ` Christopher Lameter
2019-03-26 13:36 ` Oleg Nesterov
2019-03-26 13:29 ` Oleg Nesterov
2019-03-21 21:45 ` Waiman Long [this message]
2019-03-21 21:45 ` [PATCH 4/4] mm: Do periodic rescheduling when freeing objects in kmem_free_up_q() Waiman Long
2019-03-21 22:00 ` Peter Zijlstra
2019-03-22 14:35 ` Waiman Long
2019-03-22 10:15 ` [PATCH 0/4] Signal: Fix hard lockup problem in flush_sigqueue() Matthew Wilcox
2019-03-22 11:49 ` Oleg Nesterov
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=20190321214512.11524-4-longman@redhat.com \
--to=longman@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=eparis@parisplace.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=oleg@redhat.com \
--cc=paul@paul-moore.com \
--cc=penberg@kernel.org \
--cc=peterz@infradead.org \
--cc=rientjes@google.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).