Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754070AbdLNWB1 (ORCPT ); Thu, 14 Dec 2017 17:01:27 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:31679 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753272AbdLNWAl (ORCPT ); Thu, 14 Dec 2017 17:00:41 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20171214220039epoutp0472b4d31de7e1c6240b4a768d45627625~ASC6krpww2842128421epoutp04O X-AuditID: b6c32a47-603ff70000001126-5c-5a32f4875228 From: Krzysztof Opasiak To: gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, arnd@arndb.de Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, k.lewandowsk@samsung.com, l.stelmach@samsung.com, p.szewczyk@samsung.com, Krzysztof Opasiak Subject: [RFC PATCH v2 1/4] sched: Allow to get() and put() signal struct Date: Thu, 14 Dec 2017 23:00:09 +0100 Message-id: <20171214220012.10103-2-k.opasiak@samsung.com> X-Mailer: git-send-email 2.9.3 In-reply-to: <20171214220012.10103-1-k.opasiak@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCIsWRmVeSWpSXmKPExsWy7bCmmW77F6MogxkbeS3+TjrGbtG8eD2b ReOnucwWtydOY7O4eWgFo0XHrq8sFnv2nmSxuLxrDpvFr/ntLBbn/x5ndeDy+P1rEqPH/rlr 2D36tqxi9Pi8Sc5j05O3TAGsUVw2Kak5mWWpRfp2CVwZ829PZS/o5q+YdeoyYwPjPZ4uRk4O CQETiWudU5i7GLk4hAR2MEq8uHaFEcL5zijxd8I9JpiqPceuQ1XtZpTY3nGDFcL5xSjRumw9 WxcjBwebgL7EvF2iIA0iAm4Say68ZwKpYRa4xihx7/U8dpCEsICnxMSG/2wgNouAqsTWTUuY QWxeASuJLa27oLbJSVza9gUszilgLXFkVxfYIAm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Ew2128MOiQjkbG3cIKJS 77iof8PHF3elVhaXr2IqW/d3puIC08Oz9S/PLNi/9M70rl0uglumz7GISN4vcEgi/sv1VZ+F 79+4HcvIyv1N2UgoIlJwttMZt/W7hP68vLFrXndenvnKyOsvA8ouNJ4+d2NVUmfkrM+PZn/j f3BbrlyJpTgj0VCLuag4EQBNCP6XLQIAAA== X-CMS-MailID: 20171214220038epcas2p1542bea506839523d0c657907665c6036 X-Msg-Generator: CA CMS-TYPE: 102P X-CMS-RootMailID: 20171214220038epcas2p1542bea506839523d0c657907665c6036 X-RootMTR: 20171214220038epcas2p1542bea506839523d0c657907665c6036 References: <20171214220012.10103-1-k.opasiak@samsung.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1866 Lines: 63 Allow to get() and put() signal struct from different parts of kernel core, not only from signal.c. This is useful when you place inside signal struct additional resources that has to be accessed after process dies. Signed-off-by: Krzysztof Opasiak --- include/linux/sched/signal.h | 13 +++++++++++++ kernel/fork.c | 9 ++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 0aa4548fb492..78c0c337c130 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -610,4 +610,17 @@ static inline unsigned long rlimit_max(unsigned int limit) return task_rlimit_max(current, limit); } +void free_signal_struct(struct signal_struct *sig); + +static inline void put_signal_struct(struct signal_struct *sig) +{ + if (atomic_dec_and_test(&sig->sigcnt)) + free_signal_struct(sig); +} + +static inline void get_signal_struct(struct signal_struct *sig) +{ + atomic_inc(&sig->sigcnt); +} + #endif /* _LINUX_SCHED_SIGNAL_H */ diff --git a/kernel/fork.c b/kernel/fork.c index 07cc743698d3..e54684b63c08 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -390,7 +390,7 @@ void free_task(struct task_struct *tsk) } EXPORT_SYMBOL(free_task); -static inline void free_signal_struct(struct signal_struct *sig) +void free_signal_struct(struct signal_struct *sig) { taskstats_tgid_free(sig); sched_autogroup_exit(sig); @@ -402,12 +402,7 @@ static inline void free_signal_struct(struct signal_struct *sig) mmdrop_async(sig->oom_mm); kmem_cache_free(signal_cachep, sig); } - -static inline void put_signal_struct(struct signal_struct *sig) -{ - if (atomic_dec_and_test(&sig->sigcnt)) - free_signal_struct(sig); -} +EXPORT_SYMBOL_GPL(free_signal_struct); void __put_task_struct(struct task_struct *tsk) { -- 2.9.3