Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp948379pxa; Wed, 5 Aug 2020 17:19:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjvKmF0BansQpb9tU69bCv3J4rhZNr3Ey1I/uncEJx65nNmKFinxBw81yrPwWsc3CFtXp3 X-Received: by 2002:a05:6402:206d:: with SMTP id bd13mr1717725edb.57.1596673167954; Wed, 05 Aug 2020 17:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596673167; cv=none; d=google.com; s=arc-20160816; b=vpAELHUpEJHe5jZdqdHAV5JQBAAmaheHOYHGTqKUwq+XC3lTM2K1bqu/6/SC44x3IN mewvFXGx+aOYgdsLQu0lzSLVGVpr4kk1DkaQydWaAZ7Fy4Awmk1NeeAPjXY3fE1veqKW 3aBS9dtSqHQ0WunY697stE5OVyTduA0VV5O7aDAFbfXKTZbD6MTFOhVay8ZQCiD0TJZ5 Bf6Vi/h1qy2yX1BYXGhOuZQ7uYKYOqBb9OpGixvtFwrdw4aLIpdbjxzkwbKUJNBtNo89 BpetzCTrgspXd2m9Xx/ItV1zRP3xA9Pxoma1FdI2yQgq4HVSXC2gkC9GgWCYumUA94ew rMSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=O7nU7lYRfe2R9ziGF333WHlsyARaR/Q4/HWduypodHg=; b=lxV9pjbZLzUfbL+DlfTHg8XZWaUmmTnSgqdyicocUakXMJRUO0L3TLsWClle0tsLpi vEONbO3VzvRUwEqvsR7tjDxXAwTpbVSgh3b+/Bop5MUCRPQIBIlruqizZc4g0UnIOUkk sS0IbG8ubsraO8NXKtg1fw7NF8H1j6nqOehKKl2tPtjy5HbzL/bAzgFXdhhKBRTHX2C4 OWt1GYtUNwSnKKc6YKeHRZ+0VJdyPAxDLNvXrOy0+c3mWbtao+R/xGr41KkGuZ3OO5ds 2blWBcc25rFK1jQtw1kCzjO8aBs5+7FMJ/kapQ1isv2hXKK7901FyiHho/nDFEZqzywU oGHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=P2x3Pctw; 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 t23si2643676ejj.626.2020.08.05.17.19.04; Wed, 05 Aug 2020 17:19:27 -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=P2x3Pctw; 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 S1726804AbgHFAPm (ORCPT + 99 others); Wed, 5 Aug 2020 20:15:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726726AbgHFAOx (ORCPT ); Wed, 5 Aug 2020 20:14:53 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 041DFC0617A3 for ; Wed, 5 Aug 2020 17:14:50 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id y30so5983421qvy.9 for ; Wed, 05 Aug 2020 17:14:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=O7nU7lYRfe2R9ziGF333WHlsyARaR/Q4/HWduypodHg=; b=P2x3PctwOJH5TuP9RSIAld4PsP/j3XNf0AvQXQ/DodKu083Iwcspo5T0atbcBDsOrJ 0muuNfCGfJv2UYZs4THq+0JJHbABbX5/d+U9rXKBjhLAcqh/qA9l+wDxBWI5FlGn48GT n//FasAVkPn21NR0+MvA0EQn1nxFbtKy6fABVAr7Mp1OMARjoHZ8T/jsqEcUhx3bj6/2 V+ADQDg90iYizGu72GdVwVjhB0p43nWwLP9qqQSCMCjudSGp4lbe1Y6GvsMCowNuzxah 1ljHzyW2xnvEJmsBpWAhJgQzacZvfeFe36VRxoG3XAwexV99oPDYkDxdZgV3+aIYp2vJ VEbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=O7nU7lYRfe2R9ziGF333WHlsyARaR/Q4/HWduypodHg=; b=CJvkahFqeZC+JuLNJOCsi2HhwN7j5uu4CORKwneMJyhUqoVHoRaRv7E65XBTuKVr7y JPOUguaH6raBuGUSiH9MBVlW0Va+qkJ4OYcAh5VkYYozx1MLHS4FwDVvEaUYEqgSFADt QGuZVZWIEiX8J7B5AFWuUrM1k2teakOuKjKb72a2Xr8b8DyOLQufl25fcKgdM1k2yfTp aJup5COkR0DUOd0RjwpelFddxDXJoMRYEmjGV9JLCm+0SQMiZo/MnN6jjpbADfef2z+3 11+GfGEiVhAUGEOHz/rKH6zMysCnEIB/rI/NBKoSBRlG6jr7rtk4MP89aiHEx8yCCkpA tK0w== X-Gm-Message-State: AOAM5333s0ISD5G/TpJY1UrQ6gfT8RObRSX1VsqnE54K5Us8ijdvywkY ewVscl2sKu5jP+EG2DlqPa6POZfh2XHjWD7o6VzFexyEWEuLkqxIeOWj+dJITBRWRciBsoUF827 epju0O54QCxjFWvKALtozDgXjw2oVgIWH8z232vdFxz/4lxqDc6p0cKmEUszaerDCig5ep1c= X-Received: by 2002:ad4:4ea5:: with SMTP id ed5mr6415961qvb.130.1596672885491; Wed, 05 Aug 2020 17:14:45 -0700 (PDT) Date: Wed, 5 Aug 2020 17:14:28 -0700 In-Reply-To: <20200806001431.2072150-1-jwadams@google.com> Message-Id: <20200806001431.2072150-5-jwadams@google.com> Mime-Version: 1.0 References: <20200806001431.2072150-1-jwadams@google.com> X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog Subject: [RFC PATCH 4/7] core/metricfs: expose softirq information through metricfs From: Jonathan Adams To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, Paolo Bonzini , Jim Mattson , David Rientjes , Jonathan Adams Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add metricfs support for displaying percpu softirq counters. The top directory is /sys/kernel/debug/metricfs/softirq. Then there is a subdirectory for each softirq type. For example: cat /sys/kernel/debug/metricfs/softirq/NET_RX/values Signed-off-by: Jonathan Adams --- jwadams@google.com: rebased to 5.8-pre6 This is work originally done by another engineer at google, who would rather not have their name associated with this patchset. They're okay with me sending it under my name. --- kernel/softirq.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/kernel/softirq.c b/kernel/softirq.c index c4201b7f42b1..1ae3a540b789 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include #define CREATE_TRACE_POINTS #include @@ -738,3 +740,46 @@ unsigned int __weak arch_dynirq_lower_bound(unsigned int from) { return from; } + +#ifdef CONFIG_METRICFS + +#define METRICFS_ITEM(name) \ +static void \ +metricfs_##name(struct metric_emitter *e, int cpu) \ +{ \ + int64_t v = kstat_softirqs_cpu(name##_SOFTIRQ, cpu); \ + METRIC_EMIT_PERCPU_INT(e, cpu, v); \ +} \ +METRIC_EXPORT_PERCPU_COUNTER(name, #name " softirq", metricfs_##name) + +METRICFS_ITEM(HI); +METRICFS_ITEM(TIMER); +METRICFS_ITEM(NET_TX); +METRICFS_ITEM(NET_RX); +METRICFS_ITEM(BLOCK); +METRICFS_ITEM(IRQ_POLL); +METRICFS_ITEM(TASKLET); +METRICFS_ITEM(SCHED); +METRICFS_ITEM(HRTIMER); +METRICFS_ITEM(RCU); + +static int __init init_softirq_metricfs(void) +{ + struct metricfs_subsys *subsys; + + subsys = metricfs_create_subsys("softirq", NULL); + metric_init_HI(subsys); + metric_init_TIMER(subsys); + metric_init_NET_TX(subsys); + metric_init_NET_RX(subsys); + metric_init_BLOCK(subsys); + metric_init_IRQ_POLL(subsys); + metric_init_TASKLET(subsys); + metric_init_SCHED(subsys); + metric_init_RCU(subsys); + + return 0; +} +module_init(init_softirq_metricfs); + +#endif -- 2.28.0.236.gb10cc79966-goog