From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bombadil.infradead.org ([198.137.202.9]:36408 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754268AbbESHjK (ORCPT ); Tue, 19 May 2015 03:39:10 -0400 Date: Tue, 19 May 2015 09:39:06 +0200 From: Peter Zijlstra To: Zhiqiang Zhang Cc: stable@vger.kernel.org, gregkh@linuxfoundation.org, mingo@kernel.org, morgan.wang@huawei.com Subject: Re: [PATCH] perf/x86: Further optimize copy_from_user_nmi() Message-ID: <20150519073906.GC19282@twins.programming.kicks-ass.net> References: <1432008519-30608-1-git-send-email-zhangzhiqiang.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1432008519-30608-1-git-send-email-zhangzhiqiang.zhang@huawei.com> Sender: stable-owner@vger.kernel.org List-ID: On Tue, May 19, 2015 at 12:08:39PM +0800, Zhiqiang Zhang wrote: > commit e00b12e64be9a34ef071de7b6052ca9ea29dd460 upstream > > Now that we can deal with nested NMI due to IRET re-enabling NMIs and > can deal with faults from NMI by making sure we preserve CR2 over NMIs > we can in fact simply access user-space memory from NMI context. > > So rewrite copy_from_user_nmi() to use __copy_from_user_inatomic() and > rework the fault path to do the minimal required work before taking > the in_atomic() fault handler. > > In particular avoid perf_sw_event() which would make perf recurse on > itself (it should be harmless as our recursion protections should be > able to deal with this -- but why tempt fate). > > Also rename notify_page_fault() to kprobes_fault() as that is a much > better name; there is no notifier in it and its specific to kprobes. > > Don measured that his worst case NMI path shrunk from ~300K cycles to > ~150K cycles. > > Cc: Stephane Eranian > Cc: jmario@redhat.com > Cc: Arnaldo Carvalho de Melo > Cc: Linus Torvalds > Cc: Andi Kleen > Cc: dave.hansen@linux.intel.com > Tested-by: Don Zickus > Signed-off-by: Peter Zijlstra > Link: http://lkml.kernel.org/r/20131024105206.GM2490@laptop.programming.kicks-ass.net > Signed-off-by: Ingo Molnar > [zhangzhiqiang: backport to 3.10: Did you make sure all the nested NMI fixes are in 3.10?