linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 0/6] treewide: Remove redundant branch predictions around signal_pending family
@ 2018-11-16  0:27 Davidlohr Bueso
  2018-11-16  0:27 ` [PATCH 1/6] locking/mutex: Remove caller signal_pending branch predictions Davidlohr Bueso
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Davidlohr Bueso @ 2018-11-16  0:27 UTC (permalink / raw)
  To: akpm; +Cc: dave, linux-kernel

Hi,

This series trivially gets rid of users of signal_pending (and family) explicitly
wrapping the call around an unlikely(). It is redundant as internally this is
already done for us via signal_pending() and [__]fatal_signal_pending().

All patches are independent, so I split it up in case folks want to pick up bits
separately.

Compile tested only. Please consider for v4.21.

Thanks!

Davidlohr Bueso (6):
  locking/mutex: Remove caller signal_pending branch predictions
  kernel/sched: Remove caller signal_pending branch predictions
  arch/arc: Remove caller signal_pending_branch predictions
  mm: Remove caller signal_pending branch predictions
  drivers/i2c: Remove caller signal_pending branch predictions
  fs: Remove caller signal_pending branch predictions

 arch/arc/mm/fault.c              | 2 +-
 drivers/i2c/busses/i2c-ibm_iic.c | 2 +-
 fs/afs/fs_probe.c                | 2 +-
 fs/afs/vl_probe.c                | 2 +-
 fs/buffer.c                      | 2 +-
 fs/exec.c                        | 4 ++--
 fs/orangefs/orangefs-bufmap.c    | 2 +-
 kernel/locking/mutex.c           | 2 +-
 kernel/sched/core.c              | 2 +-
 kernel/sched/swait.c             | 2 +-
 kernel/sched/wait.c              | 2 +-
 mm/filemap.c                     | 2 +-
 mm/gup.c                         | 2 +-
 mm/hugetlb.c                     | 2 +-
 14 files changed, 15 insertions(+), 15 deletions(-)

-- 
2.16.4


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

* [PATCH 1/6] locking/mutex: Remove caller signal_pending branch predictions
  2018-11-16  0:27 [PATCH -next 0/6] treewide: Remove redundant branch predictions around signal_pending family Davidlohr Bueso
@ 2018-11-16  0:27 ` Davidlohr Bueso
  2018-11-16  0:27 ` [PATCH 2/6] kernel/sched: " Davidlohr Bueso
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Davidlohr Bueso @ 2018-11-16  0:27 UTC (permalink / raw)
  To: akpm; +Cc: dave, linux-kernel, peterz, mingo

This is already done for us internally by the signal machinery.

Cc: peterz@infradead.org
Cc: mingo@kernel.org
Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 kernel/locking/mutex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
index 3f8a35104285..db578783dd36 100644
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -987,7 +987,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 		 * wait_lock. This ensures the lock cancellation is ordered
 		 * against mutex_unlock() and wake-ups do not go missing.
 		 */
-		if (unlikely(signal_pending_state(state, current))) {
+		if (signal_pending_state(state, current)) {
 			ret = -EINTR;
 			goto err;
 		}
-- 
2.16.4


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

* [PATCH 2/6] kernel/sched: Remove caller signal_pending branch predictions
  2018-11-16  0:27 [PATCH -next 0/6] treewide: Remove redundant branch predictions around signal_pending family Davidlohr Bueso
  2018-11-16  0:27 ` [PATCH 1/6] locking/mutex: Remove caller signal_pending branch predictions Davidlohr Bueso
@ 2018-11-16  0:27 ` Davidlohr Bueso
  2018-11-16  0:27 ` [PATCH 3/6] arch/arc: Remove caller signal_pending_branch predictions Davidlohr Bueso
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Davidlohr Bueso @ 2018-11-16  0:27 UTC (permalink / raw)
  To: akpm; +Cc: dave, linux-kernel, peterz, mingo

This is already done for us internally by the signal machinery.

Cc: peterz@infradead.org
Cc: mingo@kernel.org
Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 kernel/sched/core.c  | 2 +-
 kernel/sched/swait.c | 2 +-
 kernel/sched/wait.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index f12225f26b70..1972b4c63a1f 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3416,7 +3416,7 @@ static void __sched notrace __schedule(bool preempt)
 
 	switch_count = &prev->nivcsw;
 	if (!preempt && prev->state) {
-		if (unlikely(signal_pending_state(prev->state, prev))) {
+		if (signal_pending_state(prev->state, prev)) {
 			prev->state = TASK_RUNNING;
 		} else {
 			deactivate_task(rq, prev, DEQUEUE_SLEEP | DEQUEUE_NOCLOCK);
diff --git a/kernel/sched/swait.c b/kernel/sched/swait.c
index 66b59ac77c22..e83a3f8449f6 100644
--- a/kernel/sched/swait.c
+++ b/kernel/sched/swait.c
@@ -93,7 +93,7 @@ long prepare_to_swait_event(struct swait_queue_head *q, struct swait_queue *wait
 	long ret = 0;
 
 	raw_spin_lock_irqsave(&q->lock, flags);
-	if (unlikely(signal_pending_state(state, current))) {
+	if (signal_pending_state(state, current)) {
 		/*
 		 * See prepare_to_wait_event(). TL;DR, subsequent swake_up_one()
 		 * must not see us.
diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c
index 5dd47f1103d1..6eb1f8efd221 100644
--- a/kernel/sched/wait.c
+++ b/kernel/sched/wait.c
@@ -264,7 +264,7 @@ long prepare_to_wait_event(struct wait_queue_head *wq_head, struct wait_queue_en
 	long ret = 0;
 
 	spin_lock_irqsave(&wq_head->lock, flags);
-	if (unlikely(signal_pending_state(state, current))) {
+	if (signal_pending_state(state, current)) {
 		/*
 		 * Exclusive waiter must not fail if it was selected by wakeup,
 		 * it should "consume" the condition we were waiting for.
-- 
2.16.4


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

* [PATCH 3/6] arch/arc: Remove caller signal_pending_branch predictions
  2018-11-16  0:27 [PATCH -next 0/6] treewide: Remove redundant branch predictions around signal_pending family Davidlohr Bueso
  2018-11-16  0:27 ` [PATCH 1/6] locking/mutex: Remove caller signal_pending branch predictions Davidlohr Bueso
  2018-11-16  0:27 ` [PATCH 2/6] kernel/sched: " Davidlohr Bueso
@ 2018-11-16  0:27 ` Davidlohr Bueso
  2018-11-16  0:27 ` [PATCH 4/6] mm: Remove caller signal_pending branch predictions Davidlohr Bueso
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Davidlohr Bueso @ 2018-11-16  0:27 UTC (permalink / raw)
  To: akpm; +Cc: dave, linux-kernel, vgupta

This is already done for us internally by the signal machinery.

Cc: vgupta@synopsys.com
Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 arch/arc/mm/fault.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index c9da6102eb4f..6b6df8f9f882 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -142,7 +142,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
 	fault = handle_mm_fault(vma, address, flags);
 
 	/* If Pagefault was interrupted by SIGKILL, exit page fault "early" */
-	if (unlikely(fatal_signal_pending(current))) {
+	if (fatal_signal_pending(current)) {
 		if ((fault & VM_FAULT_ERROR) && !(fault & VM_FAULT_RETRY))
 			up_read(&mm->mmap_sem);
 		if (user_mode(regs))
-- 
2.16.4


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

* [PATCH 4/6] mm: Remove caller signal_pending branch predictions
  2018-11-16  0:27 [PATCH -next 0/6] treewide: Remove redundant branch predictions around signal_pending family Davidlohr Bueso
                   ` (2 preceding siblings ...)
  2018-11-16  0:27 ` [PATCH 3/6] arch/arc: Remove caller signal_pending_branch predictions Davidlohr Bueso
@ 2018-11-16  0:27 ` Davidlohr Bueso
  2018-11-16  0:27 ` [PATCH 5/6] drivers/i2c: " Davidlohr Bueso
  2018-11-16  0:27 ` [PATCH 6/6] fs: " Davidlohr Bueso
  5 siblings, 0 replies; 8+ messages in thread
From: Davidlohr Bueso @ 2018-11-16  0:27 UTC (permalink / raw)
  To: akpm; +Cc: dave, linux-kernel

This is already done for us internally by the signal machinery.

Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 mm/filemap.c | 2 +-
 mm/gup.c     | 2 +-
 mm/hugetlb.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 81adec8ee02c..abd6c4591855 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1096,7 +1096,7 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
 				break;
 		}
 
-		if (unlikely(signal_pending_state(state, current))) {
+		if (signal_pending_state(state, current)) {
 			ret = -EINTR;
 			break;
 		}
diff --git a/mm/gup.c b/mm/gup.c
index f76e77a2d34b..391c71dde267 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -722,7 +722,7 @@ static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
 		 * If we have a pending SIGKILL, don't keep faulting pages and
 		 * potentially allocating memory.
 		 */
-		if (unlikely(fatal_signal_pending(current))) {
+		if (fatal_signal_pending(current)) {
 			ret = -ERESTARTSYS;
 			goto out;
 		}
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index c007fb5fb8d5..da798bc2e948 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4184,7 +4184,7 @@ long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
 		 * If we have a pending SIGKILL, don't keep faulting pages and
 		 * potentially allocating memory.
 		 */
-		if (unlikely(fatal_signal_pending(current))) {
+		if (fatal_signal_pending(current)) {
 			remainder = 0;
 			break;
 		}
-- 
2.16.4


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

* [PATCH 5/6] drivers/i2c: Remove caller signal_pending branch predictions
  2018-11-16  0:27 [PATCH -next 0/6] treewide: Remove redundant branch predictions around signal_pending family Davidlohr Bueso
                   ` (3 preceding siblings ...)
  2018-11-16  0:27 ` [PATCH 4/6] mm: Remove caller signal_pending branch predictions Davidlohr Bueso
@ 2018-11-16  0:27 ` Davidlohr Bueso
  2018-11-27 12:01   ` [5/6] " Wolfram Sang
  2018-11-16  0:27 ` [PATCH 6/6] fs: " Davidlohr Bueso
  5 siblings, 1 reply; 8+ messages in thread
From: Davidlohr Bueso @ 2018-11-16  0:27 UTC (permalink / raw)
  To: akpm; +Cc: dave, linux-kernel, linux-i2c, peda

This is already done for us internally by the signal machinery.

Cc: linux-i2c@vger.kernel.org
Cc: peda@axentia.se
Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 drivers/i2c/busses/i2c-ibm_iic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 6f6e1dfe7cce..d78023d42a35 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -437,7 +437,7 @@ static int iic_wait_for_tc(struct ibm_iic_private* dev){
 				break;
 			}
 
-			if (unlikely(signal_pending(current))){
+			if (signal_pending(current)){
 				DBG("%d: poll interrupted\n", dev->idx);
 				ret = -ERESTARTSYS;
 				break;
-- 
2.16.4


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

* [PATCH 6/6] fs: Remove caller signal_pending branch predictions
  2018-11-16  0:27 [PATCH -next 0/6] treewide: Remove redundant branch predictions around signal_pending family Davidlohr Bueso
                   ` (4 preceding siblings ...)
  2018-11-16  0:27 ` [PATCH 5/6] drivers/i2c: " Davidlohr Bueso
@ 2018-11-16  0:27 ` Davidlohr Bueso
  5 siblings, 0 replies; 8+ messages in thread
From: Davidlohr Bueso @ 2018-11-16  0:27 UTC (permalink / raw)
  To: akpm; +Cc: dave, linux-kernel, linux-fsdevel

This is already done for us internally by the signal machinery.

Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 fs/afs/fs_probe.c             | 2 +-
 fs/afs/vl_probe.c             | 2 +-
 fs/buffer.c                   | 2 +-
 fs/exec.c                     | 4 ++--
 fs/orangefs/orangefs-bufmap.c | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/afs/fs_probe.c b/fs/afs/fs_probe.c
index d049cb459742..428588fb38c6 100644
--- a/fs/afs/fs_probe.c
+++ b/fs/afs/fs_probe.c
@@ -238,7 +238,7 @@ int afs_wait_for_fs_probes(struct afs_server_list *slist, unsigned long untried)
 			}
 		}
 
-		if (!still_probing || unlikely(signal_pending(current)))
+		if (!still_probing || signal_pending(current))
 			goto stop;
 		schedule();
 	}
diff --git a/fs/afs/vl_probe.c b/fs/afs/vl_probe.c
index c0f616bd70cb..60069640b33d 100644
--- a/fs/afs/vl_probe.c
+++ b/fs/afs/vl_probe.c
@@ -239,7 +239,7 @@ int afs_wait_for_vl_probes(struct afs_vlserver_list *vllist,
 			}
 		}
 
-		if (!still_probing || unlikely(signal_pending(current)))
+		if (!still_probing || signal_pending(current))
 			goto stop;
 		schedule();
 	}
diff --git a/fs/buffer.c b/fs/buffer.c
index 1286c2b95498..f88ee2bb62fc 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2366,7 +2366,7 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping,
 
 		balance_dirty_pages_ratelimited(mapping);
 
-		if (unlikely(fatal_signal_pending(current))) {
+		if (fatal_signal_pending(current))) {
 			err = -EINTR;
 			goto out;
 		}
diff --git a/fs/exec.c b/fs/exec.c
index fc281b738a98..2bb8bece54cc 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1084,7 +1084,7 @@ static int de_thread(struct task_struct *tsk)
 		__set_current_state(TASK_KILLABLE);
 		spin_unlock_irq(lock);
 		schedule();
-		if (unlikely(__fatal_signal_pending(tsk)))
+		if (__fatal_signal_pending(tsk))
 			goto killed;
 		spin_lock_irq(lock);
 	}
@@ -1112,7 +1112,7 @@ static int de_thread(struct task_struct *tsk)
 			write_unlock_irq(&tasklist_lock);
 			cgroup_threadgroup_change_end(tsk);
 			schedule();
-			if (unlikely(__fatal_signal_pending(tsk)))
+			if (__fatal_signal_pending(tsk))
 				goto killed;
 		}
 
diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c
index c4e98c9c1621..443bcd8c3c19 100644
--- a/fs/orangefs/orangefs-bufmap.c
+++ b/fs/orangefs/orangefs-bufmap.c
@@ -105,7 +105,7 @@ static int wait_for_free(struct slot_map *m)
 			left = t;
 		else
 			left = t + (left - n);
-		if (unlikely(signal_pending(current)))
+		if (signal_pending(current))
 			left = -EINTR;
 	} while (left > 0);
 
-- 
2.16.4


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

* Re: [5/6] drivers/i2c: Remove caller signal_pending branch predictions
  2018-11-16  0:27 ` [PATCH 5/6] drivers/i2c: " Davidlohr Bueso
@ 2018-11-27 12:01   ` Wolfram Sang
  0 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2018-11-27 12:01 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: akpm, linux-kernel, linux-i2c, peda

[-- Attachment #1: Type: text/plain, Size: 365 bytes --]

On Thu, Nov 15, 2018 at 04:27:12PM -0800, Davidlohr Bueso wrote:
> This is already done for us internally by the signal machinery.
> 
> Cc: linux-i2c@vger.kernel.org
> Cc: peda@axentia.se
> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>

Applied to for-next, thanks!

Would have been nice if the cover letter was also sent to the
i2c-mailing list.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2018-11-27 12:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-16  0:27 [PATCH -next 0/6] treewide: Remove redundant branch predictions around signal_pending family Davidlohr Bueso
2018-11-16  0:27 ` [PATCH 1/6] locking/mutex: Remove caller signal_pending branch predictions Davidlohr Bueso
2018-11-16  0:27 ` [PATCH 2/6] kernel/sched: " Davidlohr Bueso
2018-11-16  0:27 ` [PATCH 3/6] arch/arc: Remove caller signal_pending_branch predictions Davidlohr Bueso
2018-11-16  0:27 ` [PATCH 4/6] mm: Remove caller signal_pending branch predictions Davidlohr Bueso
2018-11-16  0:27 ` [PATCH 5/6] drivers/i2c: " Davidlohr Bueso
2018-11-27 12:01   ` [5/6] " Wolfram Sang
2018-11-16  0:27 ` [PATCH 6/6] fs: " Davidlohr Bueso

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).