Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp47554pxk; Wed, 30 Sep 2020 17:27:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRezpNkWg6WLDcNsY2d42QVS+tP5f0ONGS265loZBFxDM5p9QA697NsR5hcM2uava1qtFj X-Received: by 2002:a17:906:cf82:: with SMTP id um2mr5417939ejb.49.1601512070138; Wed, 30 Sep 2020 17:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601512070; cv=none; d=google.com; s=arc-20160816; b=ZFDmsZg8zeHoMjBtkEMfK7VB0blKgY/zGdHVVTPps1Uz8HxvYIuOi2Y9dEDNXNmMHa 5NaMURFS8YwlbscUL8WLhZZa2hPlE9rECNI2tL00xPDatUNICmkE8z2qHnnbiK3wqz7n mUUgsxj83BMwTBRccTI7/9sDJjMgNHjhedCvcfFXgcsK1EHraSDdvbDKLpOfBw9G2bm9 QvH52xnZyx5O5QItEuEnX4o0yplhkmUgiFfyLnQ7wSAKGCtwNJV0zcEyesFdKVaCOYDI nDqPWARBwfUUa0TUabhvOmnU8QaEQgwM11hKptnjrgfeATnXPsG+CWKaO4YhNXXdVg+e i0jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=HNMsU5r50aBHRIDtaWlPSANLm0F4Ze9torbe8s0tQL4=; b=GYDGA+uisNVYu+cLVeJvoXfvjlNUf8xxtAYvrDgeLUWNV94aRnfxxT8z0fdM3DzA1u ZhLyt/nZuq9UuKlD/NnlI3R6hDZ1OXyWrVoa+JaRewO1R3bjuSUbknLmNoJNTbHmMiOp 87v18lG7cywDTvrjSu1uZexstRm7vlgfzwOR8wQWvZml8muzrmj0rXBx7+eqmr3UC5Ju frErDoJSUr+jjOdwJErS3HQkcCR3VwqV1rcqUMd7mMfPqYroOMqWYPfP+qDp81B+Vt6a vGiYdr48bl9XmjUtdOHSZklVJNMHHS0w6HeUU4peRe8tWwDufMCtM4TiTqxoqmV00d4Y 8nLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LK8EcwIg; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q4si391914ejr.240.2020.09.30.17.27.27; Wed, 30 Sep 2020 17:27:50 -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=@google.com header.s=20161025 header.b=LK8EcwIg; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731689AbgI3Wp0 (ORCPT + 99 others); Wed, 30 Sep 2020 18:45:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729980AbgI3Wp0 (ORCPT ); Wed, 30 Sep 2020 18:45:26 -0400 Received: from mail-yb1-xb44.google.com (mail-yb1-xb44.google.com [IPv6:2607:f8b0:4864:20::b44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EED6CC061755 for ; Wed, 30 Sep 2020 15:45:25 -0700 (PDT) Received: by mail-yb1-xb44.google.com with SMTP id 67so2519032ybt.6 for ; Wed, 30 Sep 2020 15:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HNMsU5r50aBHRIDtaWlPSANLm0F4Ze9torbe8s0tQL4=; b=LK8EcwIgnuzNkqO2orIXHbbd0uXWaGlVAPmcHAMHuf/b7JpEavdShwR9odCfydZNVD wABLcr2zLhBfvkGaotF4jnc/teHUoEQ2hD+viRfcf3+Cl1E+WZlglVOXgVZ4iE63Pquh /1duSnBqgTF86DNOeBptfZsUnUYWmUsQ/JtF4XBPAefjUkTiLmtvBtpCiNODwDRvNAa2 hERxVgFcENCdiDN7i/5sbqwb73ivo3cEuDMEKdzc6ZDIl7RjqEOLtWa9S4gXXPRY2qwY E0wf61dwCdrlkiSwsHNWswoRow8PfQU3O7wm80X/zdv47e8y+KiY1DDKUu//JeDABy5n 0yOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HNMsU5r50aBHRIDtaWlPSANLm0F4Ze9torbe8s0tQL4=; b=nCfCYCofq5j9NPsoPcfetsrKHOzaHEBEt8+wSIuSazKFIQVwvFhnvVa6mdxYv1l8oz DAH9+7Q5ZzIZ8klVqeJ4dPTGXJRrjoUjlV7S4uF0jgx2cib2kzUs68lCBzdhp6+3chHh A86MChHplnozB4LBLCEMZZQa2XoCTPjxlO07OyJlK1dREn+l0u/WwxxGbhWnHuS2MMnG Pw28kLly8iSfuwDpIMHOFbP5QOp0V0mffuEQ5qFjpFwH204hEN3vy/4V74itMvBtn9L3 MmnXiEGHGVChdLbLHVhpOcHBZRDyERd6ElIoYPlql9+j4gr3uxlsvc/OTjeUg996Gh4G vNjQ== X-Gm-Message-State: AOAM533jhfUguDVE8lvGzeECBz1oUm3Rque5pV9I+1wwoLZa5MQjWbfK m9Lzh/cqjPDBNVG3AZULPYU2VnOhb/70HDtvdLMZdA== X-Received: by 2002:a25:b1a3:: with SMTP id h35mr6223422ybj.136.1601505924949; Wed, 30 Sep 2020 15:45:24 -0700 (PDT) MIME-Version: 1.0 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> <20200930173042.GD2628@hirez.programming.kicks-ass.net> In-Reply-To: <20200930173042.GD2628@hirez.programming.kicks-ass.net> From: Stephane Eranian Date: Wed, 30 Sep 2020 15:45:13 -0700 Message-ID: Subject: Re: [PATCH V8 1/4] perf/core: Add PERF_SAMPLE_DATA_PAGE_SIZE To: Peter Zijlstra Cc: Dave Hansen , "Liang, Kan" , 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 30, 2020 at 10:30 AM Peter Zijlstra wrote: > > 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. > I think Peter is right. This code is called in the context of NMI, so if active_mm is set to NULL inside a locked section, this is not enough to protect the perf_events code from seeing it. > 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; > >