Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752791AbdHAUwD (ORCPT ); Tue, 1 Aug 2017 16:52:03 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34456 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752610AbdHAUwA (ORCPT ); Tue, 1 Aug 2017 16:52:00 -0400 Date: Tue, 1 Aug 2017 23:51:57 +0300 From: "Kirill A. Shutemov" To: "Liang, Kan" Cc: Andrew Morton , "linux-kernel@vger.kernel.org" , "axboe@fb.com" , "viro@zeniv.linux.org.uk" , "kirill.shutemov@linux.intel.com" , "Huang, Ying" , "npiggin@gmail.com" , "mingo@kernel.org" Subject: Re: [PATCH] mm: allow page_cache_get_speculative in interrupt context Message-ID: <20170801205157.xaec4fcfekxmgxsl@node.shutemov.name> References: <1501609146-59730-1-git-send-email-kan.liang@intel.com> <20170801124918.af266c95fa6671e6cc1dc136@linux-foundation.org> <37D7C6CF3E00A74B8858931C1DB2F0775372496B@SHSMSX103.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <37D7C6CF3E00A74B8858931C1DB2F0775372496B@SHSMSX103.ccr.corp.intel.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1967 Lines: 48 On Tue, Aug 01, 2017 at 08:31:14PM +0000, Liang, Kan wrote: > > > > On Tue, 1 Aug 2017 13:39:06 -0400 kan.liang@intel.com wrote: > > > > > Kernel panic when calling the IRQ-safe __get_user_pages_fast in NMI > > > handler. > > > > > > The bug was introduced by commit: > > > > > > 2947ba054a4d ("x86/mm/gup: Switch GUP to the generic > > > get_user_page_fast() implementation") > > > > > > The original x86 __get_user_page_fast used plain get_page() or > > > page_ref_add(). However, the generic __get_user_page_fast uses > > > page_cache_get_speculative(), which has VM_BUG_ON(in_interrupt()). > > > > > > There is no reason to prevent page_cache_get_speculative from using in > > > interrupt context. According to the author, putting a BUG_ON there is > > > just because the code is not verifying correctness of interrupt races. > > > I did some tests in interrupt context. There is no issue found. > > > Removing VM_BUG_ON(in_interrupt()) for page_cache_get_speculative(). > > > > What code calls page_cache_get_speculative() from NMI context? > > > > The code I'm implementing will call __get_user_page_fast from NMI context. > __get_user_page_fast will eventually call page_cache_get_speculative(). > > > I'm trying to work out which kernel versions need this fix, but there isn't > > enough info in the changelog for this. Please don't do that. > > Sorry for the confusion. > > According to the comments, __get_user_page_fast should be IRQ-safe. But it's not. > This patch could be used to resolve the inconsistencies between the comments > and implementations for now. > The generic __get_user_page_fast was introduced by the commit > 2667f50e8b81457fcb4a3dbe6aff3e81ea009e13 > mm: introduce a general RCU get_user_pages_fast() > I think the kernel after the commit should be fixed. I don't think so. It's 2+ year in and nobody stepped onto this until you with your patchset. There is no real reason to get it backported. -- Kirill A. Shutemov