From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andi Kleen Subject: Re: [RFC PATCH for 4.15 09/14] Provide cpu_opv system call Date: Fri, 13 Oct 2017 19:50:30 -0700 Message-ID: <20171014025029.GL2482@two.firstfloor.org> References: <20171012230326.19984-1-mathieu.desnoyers@efficios.com> <20171012230326.19984-10-mathieu.desnoyers@efficios.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20171012230326.19984-10-mathieu.desnoyers-vg+e7yoeK/dWk0Htik3J/w@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Mathieu Desnoyers Cc: "Paul E. McKenney" , Boqun Feng , Peter Zijlstra , Paul Turner , Andrew Hunter , Andy Lutomirski , Dave Watson , Josh Triplett , Will Deacon , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Thomas Gleixner , Andi Kleen , Chris Lameter , Ingo Molnar , "H. Peter Anvin" , Ben Maurer , Steven Rostedt , Linus Torvalds , Andrew Morton , Russell King , Catalin Marinas List-Id: linux-api@vger.kernel.org > + pagefault_disable(); > + switch (len) { > + case 1: > + if (__get_user(tmp._u8, (uint8_t __user *)p)) > + goto end; > + tmp._u8 += (uint8_t)count; > + if (__put_user(tmp._u8, (uint8_t __user *)p)) > + goto end; > + break; It seems the code size could be dramatically shrunk by using a function pointer callback for the actual operation, and then avoiding all the copies. Since this is only a fallback this shouldn't be a problem (and modern branch predictors are fairly good in such situations anyways) If you really want to keep the code it would be better if you used some macros -- i bet there's a typo in here somewhere in this forest. -Andi