Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4745481pxk; Wed, 30 Sep 2020 10:32:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1tV1T/MesWe/WmiMDmfYeCzRLIpxDSucf/87IMZHu5Yci9y61uJbloZbkhSw/SdHW59g/ X-Received: by 2002:a17:906:915:: with SMTP id i21mr3861874ejd.113.1601487164742; Wed, 30 Sep 2020 10:32:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601487164; cv=none; d=google.com; s=arc-20160816; b=dWkyarQJL1NyC2QH20UoD0i5mJWcnXP+lW0CEbiHxOVn0ahrJd5wA91EhCe6xwGydD lzwqv33NhQpYOsJm6aHw9gki7soPlIzo4wHKMtBFy/FTN5O7vztbcAkqe03M0Kyv5csE nF5M53N3b9ktbux4936oeaDD0eWy/Od7B74IoMVVtgK1Yq4aowiNwrc0Cb6xKYw/ZxDW jGr7qey0OUnK8Fc2GzUUfC6JaR//CTz77ODeV2s1tAQgtEpT4+CcKrRGOBjrj3JS8zgh u3GLEgdiT96Rj4JMHrFa96M6ue07ILZfTvVxuyizpTaHULJnRwla6p8FzFTHD5PC6e/x cNAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=H/zddBw5k8rRBltxjmAh+W4FcRk20ISTJSk1L1Vh3e8=; b=D65AJmmg3wmNypaCkPnt5xV5WgQ+aHxSVsR1MI83oENU7/B9Jpz4B+LzRdo/53mgVM N2laRz527Sz8wob4EQvwnlFAJmVcxdzW4QDJcPFfqi10vadvrpfTim+wLVwtXDFb+/XG wN7PsIT4dIxxOtSKB9tO6NHqEFqKBUSW6kscGdq8vGoE/wH83fw4Ir9TFbPhnB0Bu04X 6IDvQDHtV76eKPS921r0ZvT6GNFT3D3TRtL10Gaa/JCK7+Hv8S4H6PyTlXf5v+F5xop0 WzlXmUTyQROfFaqFxYN6EZnHI+2XNjXL7jxja2LNUBMRvYZg24jznZyLZl5QFTvb02PX BjtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=CUAyCeif; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h22si1585089edj.64.2020.09.30.10.32.22; Wed, 30 Sep 2020 10:32:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=CUAyCeif; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726574AbgI3RbA (ORCPT + 99 others); Wed, 30 Sep 2020 13:31:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725355AbgI3RbA (ORCPT ); Wed, 30 Sep 2020 13:31:00 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34F12C061755 for ; Wed, 30 Sep 2020 10:31:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=H/zddBw5k8rRBltxjmAh+W4FcRk20ISTJSk1L1Vh3e8=; b=CUAyCeifPauQ9JnJsE3BU2OT5L jkALRWP1iK0oLH7Pxa/zMy16Y/I9jBxDE0yvzSFSmWurL3Tmu2xnuLIcwtoGS2Si0L81AFlEZ/6Cf 7rzvUuD+mH4nQbhF2kfLLQo33NliZCY0hTLilpHsSnDVkNySBeLAyK2jM88+Q1NgXmWEmdKY0FCJV U1alxKhIPIttGmo99XCbs9Hec1uy7flhPCRJNfLR8fM/T8PzUBqc3QnXV3yVimWo7Ak+RA2aajo0L pmhIm6vc5E9YpOzC0bzifgIXkDKEaWjD0PwHjh08OjmPvmZg/sGA/ykKWRqR4dUqr8akZzvphBsWD T45MO74A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNfwC-0006Or-9Y; Wed, 30 Sep 2020 17:30:44 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 64B4E301179; Wed, 30 Sep 2020 19:30:42 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2B65C2026833C; Wed, 30 Sep 2020 19:30:42 +0200 (CEST) Date: Wed, 30 Sep 2020 19:30:42 +0200 From: Peter Zijlstra To: Dave Hansen Cc: "Liang, Kan" , Stephane Eranian , Ingo Molnar , Arnaldo Carvalho de Melo , LKML , Mark Rutland , Alexander Shishkin , Jiri Olsa , Andi Kleen , kirill.shutemov@linux.intel.com, Michael Ellerman , benh@kernel.crashing.org, Paul Mackerras Subject: Re: [PATCH V8 1/4] perf/core: Add PERF_SAMPLE_DATA_PAGE_SIZE Message-ID: <20200930173042.GD2628@hirez.programming.kicks-ass.net> References: <20200921152653.3924-1-kan.liang@linux.intel.com> <20200921152653.3924-2-kan.liang@linux.intel.com> <4e974520-6d0f-68af-7eb8-fa52d95ba77b@linux.intel.com> <35e875ba-2c04-8452-5105-ccacf72840d8@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <35e875ba-2c04-8452-5105-ccacf72840d8@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 30, 2020 at 07:48:48AM -0700, Dave Hansen wrote: > On 9/30/20 7:42 AM, Liang, Kan wrote: > >> When I tested on my kernel, it panicked because I suspect > >> current->active_mm could be NULL. Adding a check for NULL avoided the > >> problem. But I suspect this is not the correct solution. > > > > I guess the NULL active_mm should be a rare case. If so, I think it's > > not bad to add a check and return 0 page size. > > I think it would be best to understand why ->active_mm is NULL instead > of just papering over the problem. If it is papered over, and this is > common, you might end up effectively turning off your shiny new feature > inadvertently. context_switch() can set prev->active_mm to NULL when it transfers it to @next. It does this before @current is updated. So an NMI that comes in between this active_mm swizzling and updating @current will see !active_mm. In general though; I think using ->active_mm is a mistake though. That code should be doing something like: mm = current->mm; if (!mm) mm = &init_mm;