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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94839C433EF for ; Thu, 11 Nov 2021 08:31:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 543D7611AD for ; Thu, 11 Nov 2021 08:31:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 543D7611AD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vQ2udyAfRmRP3bpZiDVKqL/QuimMG+NQMFpUMd3IwtE=; b=fnEj3H9m8gkYJ2 pvQG32qjcmCNPcMZeLQozgCXN53sxt+pe9KjrYCYA9bNg62ZYjQeF8TSqz+O3ZFeSpeT5Inx+WMRa 5DJZm1IPablcjapbjn3aWd1tKC+zY2ZPHQzqy2ns5She9g/xC5ntmkbFQWdxsVm6C4GhZfRxFnXpK TXGfDMtkORrCSlXSaBcoc5Pa800bKIdHp0Ou7lyfZFNHatRm/oRJj/oUxPH6ibvpS320k2zAxS/Q5 KuCudT9pOZfhUBxelq6PIXQTvB81/8OoZ+oH+yKSEkDBKaqJezz/ckAJOdwHBJNnZ785F7lNptHkk j5HPkpEVfqDGZPpoD6Eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ml5TL-007VN2-8n; Thu, 11 Nov 2021 08:30:15 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ml5TI-007VMa-3V for linux-arm-kernel@lists.infradead.org; Thu, 11 Nov 2021 08:30:13 +0000 Received: by mail-pl1-x635.google.com with SMTP id q17so5158102plr.11 for ; Thu, 11 Nov 2021 00:30:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=5GRE1AC8ySaNxlQTII1kzbZOaFXJN0vLmd4wnvl9WkE=; b=byjBiInJMD5yeLnojx9Ahs1+IQkN/NLJjnQd0k7llQZEYdgbMYityInN7eZ079+S1q GfcvDwhAv2pKPr1hOwn1n//MOdA0T5H0jElXnZY/ZzcVyt9Gxvx8UUu3+vx+mZzHDX7C 9zYHJtZuaiFXqeBcfiFE+oNA9ZucwqFmZgE12sMfp8MvW33VLxJdMvQxG/Ru6mW2PoI+ glrIgSISIG1zGg+LcoH2IsOOuig4dX69zOxS30uwC+A85xzXpCAzEkTkgezRl4JmCcEn sJQ7qx2suTPtFyudvaGzTcjGcJ5u43CoLfqiTtp4Oo+bSheVJsPDAQsLxISc2aoFnAfm KfVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=5GRE1AC8ySaNxlQTII1kzbZOaFXJN0vLmd4wnvl9WkE=; b=KTgSUgGK34GjBipGFlHY2HYfQEcccpVhd/xrKPbjuVP9WuX15KvQ8SNgoJARGWLn1Z p+efEBbIDU+5W/3l2ebzY6P4brSvsTWy4+HSIY3y3qXiRDL5o7o36V2HqwTKcEeJFDI8 UkhxtZmYxEhAGAYvSzczBYSrrbnf57wbPYElCLT1565H2PSfl4nQAGYMDv6KwK/LFRm2 PXMF9tnC8QMFt4uFeHweNGOolxAIHJ/q+JVjCGHh2hHaArC/5GPw3bPlOLcLvdLnSEVe lPIwrbiFul6eoB6/gMrT1dYi2ODdxtC6HT62m/MCbrzUtWbVufYd0ZpUWlUEuUSBFebU ipUg== X-Gm-Message-State: AOAM5332gCo71Drx6xSyTGYl0TZEw27VBoyvVTSCnJHrt46e+S2zyQS/ hUvVTQMo7AuPXtYsoW3qG8oIlA== X-Google-Smtp-Source: ABdhPJx2D+UMoAhMUaW307dh+HtPDmNoWmh3lg9fYfO3S8DtmRKuYvu2XMw9/wZfHmMGZyt5P6KMnw== X-Received: by 2002:a17:90b:4b04:: with SMTP id lx4mr6454193pjb.11.1636619411324; Thu, 11 Nov 2021 00:30:11 -0800 (PST) Received: from leoy-ThinkPad-X240s ([148.163.172.147]) by smtp.gmail.com with ESMTPSA id i76sm1579434pgd.69.2021.11.11.00.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 00:30:10 -0800 (PST) Date: Thu, 11 Nov 2021 16:30:02 +0800 From: Leo Yan To: Namhyung Kim Cc: German Gomez , linux-kernel , linux-perf-users , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , John Garry , Will Deacon , Mathieu Poirier , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 4/4] perf arm-spe: Support hardware-based PID tracing Message-ID: <20211111083002.GA106401@leoy-ThinkPad-X240s> References: <20211109115020.31623-1-german.gomez@arm.com> <20211109115020.31623-5-german.gomez@arm.com> <20211111074148.GC102075@leoy-ThinkPad-X240s> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211111_003012_225377_3504E705 X-CRM114-Status: GOOD ( 20.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Namhyung, On Wed, Nov 10, 2021 at 11:59:05PM -0800, Namhyung Kim wrote: [...] > > > > +static void arm_spe_set_pid_tid_cpu(struct arm_spe *spe, > > > > + struct auxtrace_queue *queue) > > > > +{ > > > > + struct arm_spe_queue *speq = queue->priv; > > > > + pid_t tid; > > > > + > > > > + tid = machine__get_current_tid(spe->machine, speq->cpu); > > > > + if (tid != -1) { > > > > + speq->tid = tid; > > > > + thread__zput(speq->thread); > > > > + } else > > > > + speq->tid = queue->tid; > > > > + > > > > + if ((!speq->thread) && (speq->tid != -1)) { > > > > + speq->thread = machine__find_thread(spe->machine, -1, > > > > + speq->tid); > > > > + } > > > > + > > > > + if (speq->thread) { > > > > + speq->pid = speq->thread->pid_; > > > > + if (queue->cpu == -1) > > > > + speq->cpu = speq->thread->cpu; > > > > + } > > > > +} > > > > + > > > > +static int arm_spe_set_tid(struct arm_spe_queue *speq, pid_t tid) > > > > +{ > > > > + struct arm_spe *spe = speq->spe; > > > > + int err = machine__set_current_tid(spe->machine, speq->cpu, tid, tid); > > > > > > I think we should pass -1 as pid as we don't know the real pid. > > > > AFAICT, I observe one case for machine__set_current_tid() returning error > > is 'speq->cpu' is -1 (this is the case for per-thread tracing). In > > this case, if pass '-1' for pid/tid, it still will return failure. > > > > So here should return the error as it is. Am I missing anything? > > I'm not saying about the error. It's about thread status. > In the machine__set_current_tid(), it calls > machine__findnew_thread() with given pid and tid. > > I suspect it can set pid to a wrong value if the thread has > no pid value at the moment. Here we should avoid to write pid '-1' with machine__set_current_tid(). The function arm_spe_set_tid() is invoked when SPE trace data contains context packet and it passes pid coming from the context packet. On the other hand, when SPE trace data doesn't contain context packet, we relies on context switch event to set pid value. So if we pass pid '-1' in arm_spe_set_tid(), it will overwrite the pid value which has been set by context switch event. Simply say, if SPE trace data contains context packet with valid pid, perf invokes arm_spe_set_tid() to set the pid value. Otherwise, it should skip this operation and roll back to use the pid value from the context switch event. Thanks, Leo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel