mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH v2 5/6] signal: sys_sigprocmask() needs retarget_shared_pending()
@ 2011-04-27  1:35 George Spelvin
  2011-04-27  2:00 ` Linus Torvalds
  0 siblings, 1 reply; 6+ messages in thread
From: George Spelvin @ 2011-04-27  1:35 UTC (permalink / raw)
  To: torvalds; +Cc: linux, linux-kernel, oleg

> and notice how you now can do that helper function *WITHOUT* any
> conditionals, and just make it do
> 
>     sigprocmask(&clear, &set, NULL);
> 
> which handles all cases correctly (just "andn clear" + "or set") with
> no if's or switch'es.

Gripe: Arrgh, apostrophe disease!  Linus, youre picking up nasty habits.

Suggestion: Actually, the usual, more flexible implementation, is
"andn mask" + "xor set".  That gives all 4 bit operations (nop, set,
clear, and toggle) unique bit combinations.

Not that it's of any use in many cases, but it has better hack value.

That would convert to:
  switch (how) {
  case SIG_BLOCK:
      mask_bits = new_set;
      set_bits = new_set;
      break;
  case SIG_UNBLOCK:
      mask_bits = new_set;
      set_bits = 0;
      break
  case SIG_SET:
     mask_bits = low_bits | new_set;
     set_bits = new_set;
     break;
   default:
     return -EINVAL;
  }

If you prefer separate set & clear fields, with both set meaning "toggle",
which admittedly is a more elegant representation, then it's
"andn (set|clear)" + "xor set".

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [RFC PATCH v2 0/7] signal: sigprocmask fixes
@ 2011-04-18 13:44 Oleg Nesterov
  2011-04-18 17:16 ` Linus Torvalds
  0 siblings, 1 reply; 6+ messages in thread
From: Oleg Nesterov @ 2011-04-18 13:44 UTC (permalink / raw)
  To: Tejun Heo, Linus Torvalds, Andrew Morton
  Cc: Nikita V. Youshchenko, Matt Fleming, linux-kernel

Andrew, please drop V1:

	signal-introduce-retarget_shared_pending.patch
	signal-retarget_shared_pending-consider-shared-unblocked-signals-only.patch
	signal-sigprocmask-narrow-the-scope-of-sigloc.patch
	signal-sigprocmask-should-do-retarget_shared_pending.patch
	x86-signal-handle_signal-should-use-sigprocmask.patch
	x86-signal-sys_rt_sigreturn-should-use-sigprocmask.patch

Changes in V2:

	- 2/7 change retarget_shared_pending() to accept mask, not ~mask

	- 3/7 is new, it adds the optimization promised in 2/7

	- 4/7 add the small comment about current->blocked as Matt
	      suggested

	- 5/7 add the new helper, set_current_blocked(), suggested
	      by Linus

	- 8/7 is the new and a bit off-topic cleanup, but sys_rt_sigprocmask()
	      looks so annoying

Matt, I didn't dare to keep your reviewed-by tags because of the
changes above, hopefully you can re-ack.

Once again: if we need this, then we need a lot more (trivial) changes
like 6/7 and 7/7. Basically every change of ->blocked should be converted
to use set_current_blocked(). OTOH, perhaps this makes sense by itself.

Oleg.


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

end of thread, other threads:[~2011-04-27 13:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27  1:35 [PATCH v2 5/6] signal: sys_sigprocmask() needs retarget_shared_pending() George Spelvin
2011-04-27  2:00 ` Linus Torvalds
  -- strict thread matches above, loose matches on Subject: below --
2011-04-18 13:44 [RFC PATCH v2 0/7] signal: sigprocmask fixes Oleg Nesterov
2011-04-18 17:16 ` Linus Torvalds
2011-04-18 17:32   ` Oleg Nesterov
2011-04-18 17:40     ` Linus Torvalds
2011-04-23 17:59       ` [PATCH 0/3] do_sigtimedwait() needs retarget_shared_pending() Oleg Nesterov
2011-04-26 19:48         ` [PATCH v2 0/6] sigtimedwait/sigprocmask need retarget_shared_pending() Oleg Nesterov
2011-04-26 19:50           ` [PATCH v2 5/6] signal: sys_sigprocmask() needs retarget_shared_pending() Oleg Nesterov
2011-04-26 21:43             ` Linus Torvalds
2011-04-27 12:57               ` Oleg Nesterov
2011-04-27 13:04                 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®