Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752259AbdHAUbU convert rfc822-to-8bit (ORCPT ); Tue, 1 Aug 2017 16:31:20 -0400 Received: from mga03.intel.com ([134.134.136.65]:59335 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752098AbdHAUbS (ORCPT ); Tue, 1 Aug 2017 16:31:18 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,306,1498546800"; d="scan'208";a="885209878" From: "Liang, Kan" To: Andrew Morton CC: "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 Thread-Topic: [PATCH] mm: allow page_cache_get_speculative in interrupt context Thread-Index: AQHTCu1Qng3GFjhcgEmcJ8QCF5hnHqJvYo4AgACGr2A= Date: Tue, 1 Aug 2017 20:31:14 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F0775372496B@SHSMSX103.ccr.corp.intel.com> References: <1501609146-59730-1-git-send-email-kan.liang@intel.com> <20170801124918.af266c95fa6671e6cc1dc136@linux-foundation.org> In-Reply-To: <20170801124918.af266c95fa6671e6cc1dc136@linux-foundation.org> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNGQ3NWJjZDctN2NhNS00MzEyLTgxNmQtNTZiOTQzMDVhZGEyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IkF3RU03MzNRYTh1RlRDdllGOXhNSENERFdrczNEWHJsT2ZCMXRZb25LVEE9In0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1676 Lines: 42 > > 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. Thanks, Kan