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 X-Spam-Level: X-Spam-Status: No, score=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24C09C11F64 for ; Thu, 1 Jul 2021 18:07:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0978C6140D for ; Thu, 1 Jul 2021 18:07:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233900AbhGASKG (ORCPT ); Thu, 1 Jul 2021 14:10:06 -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-Google-Smtp-Source: ABdhPJzNBChzvPsQQ2LA6oEbgIiRVtSa75l3kUnxIfr0QPhzRz2WoZezHxsJFrH3t6EdtcsXm5/Cvhszfe5jCEV6P+E= 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)