From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D7E1D59F6E for ; Wed, 6 Nov 2024 20:01:56 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4XkGLp62yZz3bd4; Thu, 7 Nov 2024 07:01:54 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=95.215.58.180 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1730923314; cv=none; b=Nz11Mglb0vvU55fCBRhn1hMIZBTuF1472z4OqaXext3shtCfuRxFf55NeprrEqij6BCFWxr2PcJ+Fo6mdtx2M8xfMG4zGH8CW2VQpqeXnAlEVUkUxA5fs9BuvQ/2APkTKMfgJ/QdMF+tetruMegLjJi++rLbTKKBlm+CRs5w1UC9geGhOU9tSuFj68gdj7+Y4tcU9X2Id/PO9BSX5TxG3rw7Qqvo5HRlxw8WBKy/SyPqhwHG+t2NZ71Qwb0epfS/hFocZtvBTypyIInig/TzFQt4t08aoSUjV4BTPartKcmixQJ7SSjGzcMo0yNi3iu6xwlJCRGYyKRcaewpSL8vRA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1730923314; c=relaxed/relaxed; bh=uIYHrYeDhg7kNxYUdjNDrUK44gnqtUzRYj+2b/H+nmQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZbzAF/Of48y/pvgX4ZSJ0wts+7Jhs5ADLv74CVps0wJLvJwaQ5JUgFwIQWHDNRMvZrOcTC2wm3c2+ESGjiIkvyYQrhEQcj+gqLnsHc4Y3shguWflrstKQoLjbsuDODOhp4w+GgNq9mdwA7QA42atBxcb7YX2NHkJS+N0PQfZoS+YinvwuBoWJN90tLA/ibECfLEeS4Z0qVOIGIyp/L0w5ebDArAbUhjWoBW69h9T2a3hodW38Mfu49DDkEyvUqK/7wh2GRzyQZzUs1OuWBXV+xQQ+0i4E5QEGk1iZr5RpIbGTKvDYcmqmG4M+jWP4P90DFQQ/DngdC5HYXVHvScJPA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.dev; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=azPQPKMc; dkim-atps=neutral; spf=pass (client-ip=95.215.58.180; helo=out-180.mta1.migadu.com; envelope-from=oliver.upton@linux.dev; receiver=lists.ozlabs.org) smtp.mailfrom=linux.dev Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=azPQPKMc; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.dev (client-ip=95.215.58.180; helo=out-180.mta1.migadu.com; envelope-from=oliver.upton@linux.dev; receiver=lists.ozlabs.org) X-Greylist: delayed 470 seconds by postgrey-1.37 at boromir; Thu, 07 Nov 2024 07:01:50 AEDT Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4XkGLk4bfWz3bd2 for ; Thu, 7 Nov 2024 07:01:50 +1100 (AEDT) Date: Wed, 6 Nov 2024 11:53:07 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1730922800; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=uIYHrYeDhg7kNxYUdjNDrUK44gnqtUzRYj+2b/H+nmQ=; b=azPQPKMcRZ7n0haevtf+gW2LUqUgNTZ0txSbzF62ESJFFuZ5O81yldkwxJtbt9eMJ9rYhP N+C8TyY7NMWCBJoFUX2fQEo2lLIcOBBEbEAiDRA7VK/RvAEm4WY0TpFGNaZYNkz2wLfxEo 3CDxbqePxlmasgDPRU9wm5HtPnrmBuo= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: "Liang, Kan" Cc: Colton Lewis , kvm@vger.kernel.org, Sean Christopherson , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Will Deacon , Russell King , Catalin Marinas , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org Subject: Re: [PATCH v6 5/5] perf: Correct perf sampling with guest VMs Message-ID: References: <20241105195603.2317483-1-coltonlewis@google.com> <20241105195603.2317483-6-coltonlewis@google.com> <007cfed1-111d-45aa-b873-24cca9d4af01@linux.intel.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <007cfed1-111d-45aa-b873-24cca9d4af01@linux.intel.com> X-Migadu-Flow: FLOW_OUT On Wed, Nov 06, 2024 at 11:07:53AM -0500, Liang, Kan wrote: > > +#ifndef perf_arch_guest_misc_flags > > +static inline unsigned long perf_arch_guest_misc_flags(struct pt_regs *regs) > > +{ > > + unsigned long guest_state = perf_guest_state(); > > + > > + if (guest_state & PERF_GUEST_USER) > > + return PERF_RECORD_MISC_GUEST_USER; > > + > > + if (guest_state & PERF_GUEST_ACTIVE) > > + return PERF_RECORD_MISC_GUEST_KERNEL; > > Is there by any chance to add a PERF_GUEST_KERNEL flag in KVM? Why do we need another flag? As it stands today, the vCPU is either in user mode or kernel mode. > The PERF_GUEST_ACTIVE flag check looks really confusing. Perhaps instead: static inline unsigned long perf_arch_guest_misc_flags(struct pt_regs *regs) { unsigned long guest_state = perf_guest_state(); if (!(guest_state & PERF_GUEST_ACTIVE)) return 0; return (guest_state & PERF_GUEST_USER) ? PERF_RECORD_MISC_GUEST_USER : PERF_RECORD_MISC_GUEST_KERNEL; } -- Thanks, Oliver