From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753220AbbC3RB5 (ORCPT ); Mon, 30 Mar 2015 13:01:57 -0400 Received: from mail.skyhub.de ([78.46.96.112]:48818 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753186AbbC3RBv (ORCPT ); Mon, 30 Mar 2015 13:01:51 -0400 Date: Mon, 30 Mar 2015 18:59:56 +0200 From: Borislav Petkov To: Dave Hansen Cc: linux-kernel@vger.kernel.org, x86@kernel.org, tglx@linutronix.de, dave.hansen@linux.intel.com Subject: Re: [PATCH 15/17] x86, mpx: do 32-bit-only cmpxchg for 32-bit apps Message-ID: <20150330165956.GG19897@pd.tnic> References: <20150326183327.64807530@viggo.jf.intel.com> <20150326183353.A2A5B371@viggo.jf.intel.com> <20150327172914.GE5517@pd.tnic> <55159E89.5090007@sr71.net> <20150328083928.GA17284@pd.tnic> <5519806A.1060807@sr71.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5519806A.1060807@sr71.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 30, 2015 at 09:57:14AM -0700, Dave Hansen wrote: > > + if (is_64bit_mm(mm)) > > + return user_atomic_cmpxchg_inatomic(actual_old_val_ptr, > > + bd_entry_addr, > > + expected_old_val, > > + new_bd_entry); > > + else > > + return futex_atomic_cmpxchg_inatomic((u32 *)actual_old_val_ptr, > > + (u32 __user *)bd_entry_addr, > > + expected_old_val, > > + new_bd_entry); > > } > > That does look tempting, and I appreciate the analysis. > > But, I'd really rather not hide this behind another layer of abstraction > in order to save a few variable declarations. It's definitely _smaller_ > code, but it's a little less obvious what is going on. If you rename futex_atomic_cmpxchg_inatomic to atomic_cmpxchg_inatomic_32 or so, it is perfectly clear what's going on. if (is_64bit_mm()) return user_atomic_cmpxchg_inatomic() else /* 32-bit */ return user_atomic_cmpxchg_inatomic_32() It can't get any more obvious than that. :-D -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. --