Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932531AbbHGQJN (ORCPT ); Fri, 7 Aug 2015 12:09:13 -0400 Received: from casper.infradead.org ([85.118.1.10]:51428 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932143AbbHGQJL (ORCPT ); Fri, 7 Aug 2015 12:09:11 -0400 Date: Fri, 7 Aug 2015 18:09:07 +0200 From: Peter Zijlstra To: Vineet Gupta Cc: Oleg Nesterov , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] coredump: Replace opencoded set_mask_bits() Message-ID: <20150807160907.GQ16853@twins.programming.kicks-ass.net> References: <1438935406-5762-1-git-send-email-vgupta@synopsys.com> <20150807115710.GA16897@redhat.com> <55C4C433.5000501@synopsys.com> <20150807145737.GL16853@twins.programming.kicks-ass.net> <55C4D02A.5000902@synopsys.com> <20150807154525.GO16853@twins.programming.kicks-ass.net> <55C4D58D.8040503@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55C4D58D.8040503@synopsys.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2175 Lines: 63 On Fri, Aug 07, 2015 at 09:28:05PM +0530, Vineet Gupta wrote: > On Friday 07 August 2015 09:15 PM, Peter Zijlstra wrote: > > On Fri, Aug 07, 2015 at 09:05:06PM +0530, Vineet Gupta wrote: > >> On Friday 07 August 2015 08:27 PM, Peter Zijlstra wrote: > >>> On Fri, Aug 07, 2015 at 08:14:03PM +0530, Vineet Gupta wrote: > >>> > >>>>> 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); > >>>>> > >>> Well, you'll have atomic_or() real soon now. > >> > >> Doesn't help my cause - ipi_data_ptr is not atomic_t - hence my prev question in > >> this thread > > > > A cast will work :-) > > > > How ? We have > > typedef struct { > int counter; > } atomic_t; ARC is 32bit, right? So int and unsigned long are of the same size. Therefore: atomic_or(1 << msg, (atomic_t *)ipi_data_ptr); Ugly, yes, but it should DTRT. > > But yes, ideally everything will be type safe because of those archs > > that cannot have atomic RmW ops like !ARC_HAS_LLSC. > > Type safe - how / what ? All atomic stuff restricted to atomic*t and bitmap functions (and ideally we'd also have bitmap_t to avoid passing random unsigned long * into bitmap functions and praying it all works, we do, and it doesn't, well mostly :-). > > Mixing cmpxchg()/xchg() with regular stores is broken on those. > > Right, but how does that relate to this discussion - perhaps I shd stop talking - > long friday already :-) :-) Well, its a very good argument for why we should not use cmpxchg/xchg on !atomic*t types, and therefore why the function at hand (set_mask_bit) should really be on an atomic_t. That said, it will probably make the fs code fugly for having to use atomic_t and all its accessors all over the place. -- 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/