From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mathieu Desnoyers Subject: Re: [RFC PATCH for 4.15 09/14] Provide cpu_opv system call Date: Sat, 14 Oct 2017 13:35:28 +0000 (UTC) Message-ID: <1866208529.41181.1507988128067.JavaMail.zimbra@efficios.com> References: <20171012230326.19984-1-mathieu.desnoyers@efficios.com> <20171012230326.19984-10-mathieu.desnoyers@efficios.com> <20171014025029.GL2482@two.firstfloor.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20171014025029.GL2482-1g7Xle2YJi4/4alezvVtWx2eb7JE58TQ@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Andi Kleen Cc: "Paul E. McKenney" , Boqun Feng , Peter Zijlstra , Paul Turner , Andrew Hunter , Andy Lutomirski , Dave Watson , Josh Triplett , Will Deacon , linux-kernel , Thomas Gleixner , Chris Lameter , Ingo Molnar , "H. Peter Anvin" , Ben Maurer , rostedt , Linus Torvalds , Andrew Morton , Russell King , Catalin Marinas , Michael List-Id: linux-api@vger.kernel.org ----- On Oct 13, 2017, at 10:50 PM, Andi Kleen andi-Vw/NltI1exuRpAAqCnN02g@public.gmane.org wrote: >> + 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. Good point! I'll add this in the next round. Meanwhile, here is the resulting commit: https://github.com/compudj/linux-percpu-dev/commit/864b444f64f4c227ddc587d12631ff0d3440796c Thanks, Mathieu > > -Andi -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753714AbdJNNdm (ORCPT ); Sat, 14 Oct 2017 09:33:42 -0400 Received: from mail.efficios.com ([167.114.142.141]:35452 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751715AbdJNNdk (ORCPT ); Sat, 14 Oct 2017 09:33:40 -0400 Date: Sat, 14 Oct 2017 13:35:28 +0000 (UTC) From: Mathieu Desnoyers To: Andi Kleen Cc: "Paul E. McKenney" , Boqun Feng , Peter Zijlstra , Paul Turner , Andrew Hunter , Andy Lutomirski , Dave Watson , Josh Triplett , Will Deacon , linux-kernel , Thomas Gleixner , Chris Lameter , Ingo Molnar , "H. Peter Anvin" , Ben Maurer , rostedt , Linus Torvalds , Andrew Morton , Russell King , Catalin Marinas , Michael Kerrisk , linux-api Message-ID: <1866208529.41181.1507988128067.JavaMail.zimbra@efficios.com> In-Reply-To: <20171014025029.GL2482@two.firstfloor.org> References: <20171012230326.19984-1-mathieu.desnoyers@efficios.com> <20171012230326.19984-10-mathieu.desnoyers@efficios.com> <20171014025029.GL2482@two.firstfloor.org> Subject: Re: [RFC PATCH for 4.15 09/14] Provide cpu_opv system call MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.141] X-Mailer: Zimbra 8.7.11_GA_1854 (ZimbraWebClient - FF52 (Linux)/8.7.11_GA_1854) Thread-Topic: Provide cpu_opv system call Thread-Index: U5/4vAiBDY5BO8ea+7yQH2ZKqAkbvQ== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Oct 13, 2017, at 10:50 PM, Andi Kleen andi@firstfloor.org wrote: >> + 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. Good point! I'll add this in the next round. Meanwhile, here is the resulting commit: https://github.com/compudj/linux-percpu-dev/commit/864b444f64f4c227ddc587d12631ff0d3440796c Thanks, Mathieu > > -Andi -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com