Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753771AbbHGOoN (ORCPT ); Fri, 7 Aug 2015 10:44:13 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:32882 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753323AbbHGOoL (ORCPT ); Fri, 7 Aug 2015 10:44:11 -0400 Message-ID: <55C4C433.5000501@synopsys.com> Date: Fri, 07 Aug 2015 20:14:03 +0530 From: Vineet Gupta Organization: Synopsys User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Oleg Nesterov CC: Alexander Viro , "Peter Zijlstra (Intel)" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] coredump: Replace opencoded set_mask_bits() References: <1438935406-5762-1-git-send-email-vgupta@synopsys.com> <20150807115710.GA16897@redhat.com> In-Reply-To: <20150807115710.GA16897@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1915 Lines: 53 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 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/