From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933296AbcI3L6q (ORCPT ); Fri, 30 Sep 2016 07:58:46 -0400 Received: from terminus.zytor.com ([198.137.202.10]:44754 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932408AbcI3L6j (ORCPT ); Fri, 30 Sep 2016 07:58:39 -0400 Date: Fri, 30 Sep 2016 04:57:46 -0700 From: tip-bot for Oleg Nesterov Message-ID: Cc: linux-kernel@vger.kernel.org, hannes@cmpxchg.org, mingo@kernel.org, viro@ZenIV.linux.org.uk, efault@gmx.de, tglx@linutronix.de, torvalds@linux-foundation.org, neilb@suse.de, bvanassche@acm.org, peterz@infradead.org, oleg@redhat.com, hpa@zytor.com Reply-To: tglx@linutronix.de, oleg@redhat.com, peterz@infradead.org, bvanassche@acm.org, torvalds@linux-foundation.org, neilb@suse.de, hpa@zytor.com, linux-kernel@vger.kernel.org, mingo@kernel.org, hannes@cmpxchg.org, efault@gmx.de, viro@ZenIV.linux.org.uk In-Reply-To: <20160906140055.GA6167@redhat.com> References: <20160906140055.GA6167@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/wait: Introduce init_wait_entry() Git-Commit-ID: 0176beaffbe9ed627b6a4dfa61d640f1a848086f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 0176beaffbe9ed627b6a4dfa61d640f1a848086f Gitweb: http://git.kernel.org/tip/0176beaffbe9ed627b6a4dfa61d640f1a848086f Author: Oleg Nesterov AuthorDate: Tue, 6 Sep 2016 16:00:55 +0200 Committer: Ingo Molnar CommitDate: Fri, 30 Sep 2016 10:54:03 +0200 sched/wait: Introduce init_wait_entry() The partial initialization of wait_queue_t in prepare_to_wait_event() looks ugly. This was done to shrink .text, but we can simply add the new helper which does the full initialization and shrink the compiled code a bit more. And. This way prepare_to_wait_event() can have more users. In particular we are ready to remove the signal_pending_state() checks from wait_bit_action_f helpers and change __wait_on_bit_lock() to use prepare_to_wait_event(). Signed-off-by: Oleg Nesterov Signed-off-by: Peter Zijlstra (Intel) Cc: Al Viro Cc: Bart Van Assche Cc: Johannes Weiner Cc: Linus Torvalds Cc: Mike Galbraith Cc: Neil Brown Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20160906140055.GA6167@redhat.com Signed-off-by: Ingo Molnar --- include/linux/wait.h | 9 +++------ kernel/sched/wait.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/linux/wait.h b/include/linux/wait.h index 19c75f9..2408e8d5 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -248,6 +248,8 @@ wait_queue_head_t *bit_waitqueue(void *, int); (!__builtin_constant_p(state) || \ state == TASK_INTERRUPTIBLE || state == TASK_KILLABLE) \ +extern void init_wait_entry(wait_queue_t *__wait, int flags); + /* * The below macro ___wait_event() has an explicit shadow of the __ret * variable when used from the wait_event_*() macros. @@ -266,12 +268,7 @@ wait_queue_head_t *bit_waitqueue(void *, int); wait_queue_t __wait; \ long __ret = ret; /* explicit shadow */ \ \ - INIT_LIST_HEAD(&__wait.task_list); \ - if (exclusive) \ - __wait.flags = WQ_FLAG_EXCLUSIVE; \ - else \ - __wait.flags = 0; \ - \ + init_wait_entry(&__wait, exclusive ? WQ_FLAG_EXCLUSIVE : 0); \ for (;;) { \ long __int = prepare_to_wait_event(&wq, &__wait, state);\ \ diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c index 0cb615d..4f70535 100644 --- a/kernel/sched/wait.c +++ b/kernel/sched/wait.c @@ -196,14 +196,20 @@ prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state) } EXPORT_SYMBOL(prepare_to_wait_exclusive); +void init_wait_entry(wait_queue_t *wait, int flags) +{ + wait->flags = flags; + wait->private = current; + wait->func = autoremove_wake_function; + INIT_LIST_HEAD(&wait->task_list); +} +EXPORT_SYMBOL(init_wait_entry); + long prepare_to_wait_event(wait_queue_head_t *q, wait_queue_t *wait, int state) { unsigned long flags; long ret = 0; - wait->private = current; - wait->func = autoremove_wake_function; - spin_lock_irqsave(&q->lock, flags); if (unlikely(signal_pending_state(state, current))) { /*