From patchwork Wed Aug 14 10:41:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 171262 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp645694ily; Wed, 14 Aug 2019 03:42:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8nRR08FIi0KEzVvG5EqVKA0M58aZ8R0MQ9222bNCn7E0tKJFn6NzC0Je//meteKX5fqME X-Received: by 2002:a17:90a:b393:: with SMTP id e19mr6646085pjr.118.1565779322601; Wed, 14 Aug 2019 03:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565779322; cv=none; d=google.com; s=arc-20160816; b=hhAYAw3FsHpAedAWXouui38klGa7Gm9BSkxI7Luh+5udn7Ii3kqwCjeX/eQPMB77KB 6tt+Vdjvkw+zYjFdrSCiwTX6kRB92WZw1hIEpwbhtnF/+EdTIdHaADEU97vUZAa8WkH7 bU2PgH54MrTsGgse5IXWy+Se1RleFNbXkh9oRHI8anklvTQjzGcW2vI47dvFSLafpir9 UlktGp3aTCKNjFM9PFS5gwFv6TAoxjmU5f+k5eHmY5Ltl3zD5XDWk4m8SAsoPxqnSufd S13TnH3ConSwxAwgDH0wb6MdENJiHWhQzVIiPFAnnWOD+4HTaICzSHxHJJ/1RHhS5lz5 yRSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=EdhipERRetj+TCrj5nGZD1UXw54NwkPXvlUwxvs4T9o=; b=WTdoGCRwWHVK93y8HkTsuLBUH+0d7kXQkBxl0yn2z+MXQ1KV7b3QcMn2owstxTnGCA nKPTudbTR/685vzKhr13Dr5yVpF+Yqe8iAlznsRgd3GEoXxmoNF10Lmys8LOugDItisF zHLshPC07mo1VdOpR0QZZGDZFYZH0gRnGIO9s5WaXYSu73r5LSiEItIJMurIw+AXBXvE xmrgEBAhae83uR2jZaw69mOMQg05eYtiRNF0RIWo+IHd3R7muiFD86hg2MO7DgTan79G 8tbpxFjChirKIUWXVpiUJsoxmix+Ww7/2B/8sQbYAxGjABCYky0SjeGyRTiRWWpqw46b 2tWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si67050421pgr.514.2019.08.14.03.42.02; Wed, 14 Aug 2019 03:42:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727610AbfHNKmB (ORCPT + 28 others); Wed, 14 Aug 2019 06:42:01 -0400 Received: from foss.arm.com ([217.140.110.172]:51982 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726821AbfHNKl4 (ORCPT ); Wed, 14 Aug 2019 06:41:56 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 59CC81570; Wed, 14 Aug 2019 03:41:56 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 846FD3F706; Wed, 14 Aug 2019 03:41:54 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: ak@linux.intel.com, akpm@linux-foundation.org, bigeasy@linutronix.de, bp@suse.de, catalin.marinas@arm.com, davem@davemloft.net, hch@lst.de, kan.liang@intel.com, mark.rutland@arm.com, mingo@kernel.org, peterz@infradead.org, riel@surriel.com, will@kernel.org Subject: [PATCH 7/9] x86/lbr: correctly check for kthreads Date: Wed, 14 Aug 2019 11:41:29 +0100 Message-Id: <20190814104131.20190-8-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190814104131.20190-1-mark.rutland@arm.com> References: <20190814104131.20190-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The x86 lbr branch_type() functions looks at current->mm, apparently to determine whether the thread is a kthread without any valid user context. In general, a non-NULL current->mm doesn't imply that current is a kthread, as kthreads can install an mm via use_mm(), and so it's preferable to use is_kthread() to determine whether a thread is a kthread. For consistency, let's use is_kthread() here. Signed-off-by: Mark Rutland Cc: Andi Kleen Cc: Ingo Molnar Cc: Kan Liang Cc: Peter Zijlstra --- arch/x86/events/intel/lbr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c index 6f814a27416b..ed2b7e57a249 100644 --- a/arch/x86/events/intel/lbr.c +++ b/arch/x86/events/intel/lbr.c @@ -857,7 +857,7 @@ static int branch_type(unsigned long from, unsigned long to, int abort) * can happen if measuring at the user level only * and we interrupt in a kernel thread, e.g., idle. */ - if (!current->mm) + if (is_kthread(current)) return X86_BR_NONE; /* may fail if text not present */