All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vineet Gupta <vgupta@synopsys.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] coredump: Replace opencoded set_mask_bits()
Date: Fri, 07 Aug 2015 20:14:03 +0530	[thread overview]
Message-ID: <55C4C433.5000501@synopsys.com> (raw)
In-Reply-To: <20150807115710.GA16897@redhat.com>

On Friday 07 August 2015 05:27 PM, Oleg Nesterov wrote:
> On 08/07, Vineet Gupta wrote:
>>
>> --- a/fs/exec.c
>> +++ b/fs/exec.c
>> @@ -1690,15 +1690,10 @@ EXPORT_SYMBOL(set_binfmt);
>>   */
>>  void set_dumpable(struct mm_struct *mm, int value)
>>  {
>> -	unsigned long old, new;
>> -
>>  	if (WARN_ON((unsigned)value > SUID_DUMP_ROOT))
>>  		return;
>>  
>> -	do {
>> -		old = ACCESS_ONCE(mm->flags);
>> -		new = (old & ~MMF_DUMPABLE_MASK) | value;
>> -	} while (cmpxchg(&mm->flags, old, new) != old);
>> +	set_mask_bits(&mm->flags, MMF_DUMPABLE_MASK, value);
>>  }
> 
> Acked-by: Oleg Nesterov <oleg@redhat.com>


I have a fundamental question though, perhaps stupid, do use cases like these
warrant the data to be atomic_t in first place. Do API like set_mask_bits() make
sense at all - or shd they be moved to atomic_* (after changing the underlying data)

See, I have such a cmpxchg loop in ARC code - originally from Peter :-)
arch/arc/kernel/smp.c. @ipi_data_ptr is NOT atomic_t

	do {
		new = old = ACCESS_ONCE(*ipi_data_ptr);
		new |= 1U << msg;
	} while (cmpxchg(ipi_data_ptr, old, new) != old);


Given that ARC (and some other RISC cores) lack native cmpxchg, we use LLSC
instructions to implement atomics including cpmxchg - the implementation itself
ensures loop is builtin making the outer loping superfluous and waste of cycles
(see e.g. cover letter @ http://www.spinics.net/lists/kernel/msg2029217.html)

So I wanted to convert that loop (and similar other cases to "some" API which
could be built conditionally based on cmpxchg or llsc. None such exist and I was
thinking of converting my case to atomic_t. Is that the right approach ?

Thx,
-Vineet

  reply	other threads:[~2015-08-07 14:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-07  8:16 [PATCH] coredump: Replace opencoded set_mask_bits() Vineet Gupta
2015-08-07 11:57 ` Oleg Nesterov
2015-08-07 14:44   ` Vineet Gupta [this message]
2015-08-07 14:57     ` Peter Zijlstra
2015-08-07 15:35       ` Vineet Gupta
2015-08-07 15:45         ` Peter Zijlstra
2015-08-07 15:58           ` Vineet Gupta
2015-08-07 16:09             ` Peter Zijlstra

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=55C4C433.5000501@synopsys.com \
    --to=vgupta@synopsys.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.