From 7b36646951dc927204065f533ea352fe6dedc546 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 28 Sep 2021 21:57:31 +0900 Subject: [PATCH] lsfd: collect threads level information if TID is specified in a filter Signed-off-by: Masatake YAMATO --- misc-utils/lsfd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/misc-utils/lsfd.c b/misc-utils/lsfd.c index 8da659fbc3..3e5d65f52b 100644 --- a/misc-utils/lsfd.c +++ b/misc-utils/lsfd.c @@ -233,7 +233,7 @@ static struct libscols_column *add_column(struct libscols_table *tb, const struc return cl; } -static struct libscols_column *add_column_by_id_cb(struct libscols_table *tb, int colid, void *data __attribute__((__unused__))) +static struct libscols_column *add_column_by_id_cb(struct libscols_table *tb, int colid, void *data) { if (ncolumns >= ARRAY_SIZE(columns)) errx(EXIT_FAILURE, _("too many columns are added via filter expression")); @@ -244,6 +244,12 @@ static struct libscols_column *add_column_by_id_cb(struct libscols_table *tb, in if (!cl) err(EXIT_FAILURE, _("failed to allocate output column")); columns[ncolumns++] = colid; + + if (colid == COL_TID) { + struct lsfd_control *ctl = data; + ctl->threads = 1; + } + return cl; } @@ -1137,7 +1143,7 @@ int main(int argc, char *argv[]) ctl.filter = lsfd_filter_new(filter_expr, ctl.tb, LSFD_N_COLS, column_name_to_id_cb, - add_column_by_id_cb, NULL); + add_column_by_id_cb, &ctl); const char *errmsg = lsfd_filter_get_errmsg(ctl.filter); if (errmsg) errx(EXIT_FAILURE, "%s", errmsg); -- 2.47.3