Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp872122pxv; Thu, 1 Jul 2021 11:10:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhG2s9e+ZRnqxsFY9umvYGH7oi34LlNe9wmELUlHRbdex6DAEA6PZRGJZD1MVlcma5zkmu X-Received: by 2002:a17:906:cc87:: with SMTP id oq7mr1254394ejb.193.1625163043823; Thu, 01 Jul 2021 11:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625163043; cv=none; d=google.com; s=arc-20160816; b=RZVWYuXRzFgRW0JgfxjY6DpdMCKVOMtRljd4e8wlKOEPGxpJI85uNmNT7tIkh5PYik xUQWdR8xUvVIejRx6wV42LgtGuLPIk0Z7iOJsklPqdtKREkxa4UeYey5tZTaSQskeYie GHAphlLdTrWVtUEjPwbaHUqIYgkUyhwn6yOGtMyGMlIrWMoW2UpmHJAA+6A/4XHLJMyL i5ubOgY5+tnpjhX26V9IS/W6ZlT3q+ObwhrCAPGIJi6XbfFdhIIJPLookgqoi3yvEZ89 MJrj5g12/5J/YkUv2+F2rY2i51uF7XRbycZxBMnzUbXxfZZdbL9b+Y7AZA4u4HtbuKAL XCQQ== 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=NVSKoBt2z1qak8JlO8036fYKzXIM1f92CLbSFQ7Q3dA=; b=vMn6oz8FJlWKOcQrJ7J+L6NJkATGfH5Loci1nANYO5Nt8K6//R9eJXRkWpJd10PLo/ 0V5MrMbg7TmAm6obW+0wBOKu8tQStF2Rh4/H+1HIcC98HprkDU/WVK1+z4/r2Zu+Wt83 XeUkTs2mlRedgaeAZwF2Elp7eEaCo+bSQmuy9NVJagFNbNPXat9/QI/mAubzSkarLlrh Udi8ZBhpCe36bhteMKvNLcklJz6C+KqaQ62DOZ66Pj+fVEFQ9afvRTilTAfaIp3TOALs akpFwd44Xls/oQh/Lkae6Fj+a+ncpdTf4scMoBTMqCeHTEArlI4EZjgW3c9Pzxky6cbV 4vlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pE23NV1b; 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 p8si444476edx.277.2021.07.01.11.10.19; Thu, 01 Jul 2021 11:10:43 -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=pE23NV1b; 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 S233820AbhGASKF (ORCPT + 99 others); Thu, 1 Jul 2021 14:10:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233748AbhGASKF (ORCPT ); Thu, 1 Jul 2021 14:10:05 -0400 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EF4EC061762 for ; Thu, 1 Jul 2021 11:07:33 -0700 (PDT) Received: by mail-qv1-xf35.google.com with SMTP id m15so3414891qvc.9 for ; Thu, 01 Jul 2021 11:07:33 -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=NVSKoBt2z1qak8JlO8036fYKzXIM1f92CLbSFQ7Q3dA=; b=pE23NV1bx3tkqEhyGqVwhLzlSXgUawfHfhffIcx9gPigYmAqKOyOjtJrHf4IVRn/6C Os5t574z0ShM1THpTWuB1qF8pJ5CW6dnPVjsCnjsUI69t1/WB2zZQAtWMTIVtYpyuuRd HOy5EzLep5UP43j5zxCgQ6SZU9jHII9/9EL1bqbWzkJSa4BsvcS8Bi3j5vClIxoqDXbq NbRBydVt3TgIv6iZZrFk6ifqAZucC1gNhXSeAVs0xaai+7SINFEKKKWlhiCjm26hTKuu QLNXb4kI1jw4c/i3p+MLkRxT4f9uQ3L4NGJUsIa9bLtVhqh1pEjwGOcvvsTEovM0guNx Umpg== 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=NVSKoBt2z1qak8JlO8036fYKzXIM1f92CLbSFQ7Q3dA=; b=d/g0FxOLql109f+rNjDR4qQQ0K9Sud9e/g9GR2Cpau0na7uOobi1gsq29sBiae7JVq OYPazQOAezXTwAr3mkL2GJHdS5MMfen4Abp80dJcKGa0KrugFfSC8BfvE3pR2xc2+T7t lpEG1ZJdWFT08p3CwXAIbF7GM5/AbRxFZXecX+kQHVOKyLUa8XN1C8CpvHFec1mmeXNf Bk1uCFpV2SPEZ8iRsC6nZqcfyKGi9mllMQ+9LUJ3nCZARoKd5d+9C0lqFmCuHdTHk4Ul 7Z9GzTP6cU6xbYyl1ZRubVXyWTRARJhBtYwn4VRIenJGVNtwK24O3AZK/Djb4LYcjWh5 /mmA== X-Gm-Message-State: AOAM533TH2wnHi67WXnvqq8sxnBQjZ6uUIy7hCK/fqHPxxkZZQndj18X EQXh5Hi3IlGWpvmlobpkyWvmXXpQFQR8JfogJQgfzA== X-Received: by 2002:a0c:ed46:: with SMTP id v6mr1115038qvq.35.1625162852576; Thu, 01 Jul 2021 11:07:32 -0700 (PDT) MIME-Version: 1.0 References: <20210701095525.400839d3@oasis.local.home> <20210701172407.889626-1-paulburton@google.com> In-Reply-To: <20210701172407.889626-1-paulburton@google.com> From: Joel Fernandes Date: Thu, 1 Jul 2021 14:07:21 -0400 Message-ID: Subject: Re: [PATCH v2 1/2] tracing: Simplify & fix saved_tgids logic To: Paul Burton Cc: linux-kernel@vger.kernel.org, Steven Rostedt , Ingo Molnar , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 1, 2021 at 1:24 PM Paul Burton wrote: > > The tgid_map array records a mapping from pid to tgid, where the index > of an entry within the array is the pid & the value stored at that index > is the tgid. > > The saved_tgids_next() function iterates over pointers into the tgid_map > array & dereferences the pointers which results in the tgid, but then it > passes that dereferenced value to trace_find_tgid() which treats it as a > pid & does a further lookup within the tgid_map array. It seems likely > that the intent here was to skip over entries in tgid_map for which the > recorded tgid is zero, but instead we end up skipping over entries for > which the thread group leader hasn't yet had its own tgid recorded in > tgid_map. > > A minimal fix would be to remove the call to trace_find_tgid, turning: > > if (trace_find_tgid(*ptr)) > > into: > > if (*ptr) > > ..but it seems like this logic can be much simpler if we simply let > seq_read() iterate over the whole tgid_map array & filter out empty > entries by returning SEQ_SKIP from saved_tgids_show(). Here we take that > approach, removing the incorrect logic here entirely. > > Signed-off-by: Paul Burton > Fixes: d914ba37d714 ("tracing: Add support for recording tgid of tasks") > Cc: Steven Rostedt > Cc: Ingo Molnar > Cc: Joel Fernandes Reviewed-by: Joel Fernandes (Google)