Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5005952ybv; Wed, 26 Feb 2020 06:51:14 -0800 (PST) X-Google-Smtp-Source: APXvYqxfioUwj69iX0ntcyrggTaDZxHRBgePTsL7CemHg9LNXkL03P+3D2kK6VY7VKThc82+FigK X-Received: by 2002:a54:488d:: with SMTP id r13mr3272860oic.115.1582728674190; Wed, 26 Feb 2020 06:51:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582728674; cv=none; d=google.com; s=arc-20160816; b=zj8JXrx6ru/clVfWrgkWJQp6fZ9tUXPso0LLWHimVJdKtJziBQ88GF/X3ssLKILOD+ 0yJ1nqtj0mgQhYA0duAhLWa4ynDrrARkpU8/kYDLHg0erYRJpzH464dGfMqBtSaGzRvf zo0to2KHWHQ7NknOWqiN+czMPkc1rpx5sv3SSRzDGDzTqKO3ATUEfOSWDfs4r0XhBF54 sBPfnx1wOyOQHriXDmLrAhjlCWxFl/iQNmi3xk87PiRydUWC4Tk2hCXXHA+b9Ws1FnnX ojK0S8C8y7tKzlIdmjBdrE4EqyC0yYiBeYrPOnVyIo0p86pPH6QS1gdcp1ev2U2ATPRN mNIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:to:from:subject:message-id :dkim-signature; bh=C/fit9buLQoyBITMniA3SZzT0SvwKSgZb4ufJ9DR0s0=; b=KKQminN1uX9YggMkywv2mKBDy0Kfs5Pi2HT8ZAQKY9MMsvSHtBbxRQQ7+GSPHkr6km h8Vf1re7RUpZubqJlHUG7p0qCIFbxSoJ9PYDVl751UQaGfEJFH29XK0+xOIjHiRhkfuB 9UvrjYh2U7u4NUoW64X4mRED5hpXspm30tCvfhDRJXzmUXjVwALqXBS8/Tuc/gCUpKP/ 07aLhieb650qNDBcZg4s4x3uRPNo8/CBMS5z7U3Klh/KZxqTJB+yltbtV9cMoDXJpxh8 SfGwWEZIdy/nmA2Hzn1lU1vmWp+/rm1v6xliq05Bw04F24i/IUl88DB8+PWsCOlADdFU 3/4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WB0T68gN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w18si1564072otl.54.2020.02.26.06.51.01; Wed, 26 Feb 2020 06:51:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WB0T68gN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727895AbgBZOtC (ORCPT + 99 others); Wed, 26 Feb 2020 09:49:02 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:58073 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727584AbgBZOtC (ORCPT ); Wed, 26 Feb 2020 09:49:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582728541; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C/fit9buLQoyBITMniA3SZzT0SvwKSgZb4ufJ9DR0s0=; b=WB0T68gNA5C6tPHTc8ni7IqWLAh8C6nkEuuRUTcg4ADMkoJg1KtlCCzq0CeFtIHCptEvWT GigPOvqMBvru2NwVyCJrgDjg6PkzGWJvcTuwReAY0P7GviZTG05peGpC/8tLK9sK2Xmuqv 4DsGmvYxO78EZ58hGAnfHi35ZqlpjpY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-125-clHqMRhWO7uWL9xrfeXjXw-1; Wed, 26 Feb 2020 09:48:59 -0500 X-MC-Unique: clHqMRhWO7uWL9xrfeXjXw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3A00B13E2; Wed, 26 Feb 2020 14:48:57 +0000 (UTC) Received: from ovpn-117-20.ams2.redhat.com (ovpn-117-20.ams2.redhat.com [10.36.117.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FA978B759; Wed, 26 Feb 2020 14:48:50 +0000 (UTC) Message-ID: <6bda45c24afb5bbd069af6f57b07880cd2f5af52.camel@redhat.com> Subject: Re: [PATCH v3 1/2] kstats: kernel metric collector From: Paolo Abeni To: Luigi Rizzo , linux-kernel@vger.kernel.org, mhiramat@kernel.org, akpm@linux-foundation.org, gregkh@linuxfoundation.org, naveen.n.rao@linux.ibm.com, ardb@kernel.org, rizzo@iet.unipi.it, giuseppe.lettieri@unipi.it, toke@redhat.com, hawk@kernel.org, mingo@redhat.com, acme@kernel.org, rostedt@goodmis.org, peterz@infradead.org Date: Wed, 26 Feb 2020 15:48:49 +0100 In-Reply-To: <20200226135027.34538-2-lrizzo@google.com> References: <20200226135027.34538-1-lrizzo@google.com> <20200226135027.34538-2-lrizzo@google.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I'm sorry for the lack of feedback on earlier iteration, I've simply been too slow. On Wed, 2020-02-26 at 05:50 -0800, Luigi Rizzo wrote: [...] > +static void ks_print(struct seq_file *p, int slot, int cpu, u64 sum, > + u64 tot, unsigned long samples, unsigned long avg) > +{ > + unsigned long frac = (tot == 0) ? 0 : ((sum % tot) * 1000000) / tot; I think/fear kbuildbot will still trigger some build issues on 32bit arches on the above line. I think div64_u64_rem() should be used in place of '%' for and div64_u64() in place of '/' when operating on 64bits integers. There are a few more occurences below. [...] > ++ /* preempt_disable makes sure samples and sum modify the same slot. > + * this_cpu_add() uses a non-interruptible add to protect against > + * hardware interrupts which may call kstats_record. > + */ > + preempt_disable(); > + this_cpu_add(ks->slots[slot].samples, 1); I think 'this_cpu_inc()' could be used here. > + this_cpu_add(ks->slots[slot].sum, > + bucket < SUM_SCALE ? val : (val >> (bucket - SUM_SCALE))); > + preempt_enable(); > +} > +EXPORT_SYMBOL(kstats_record); Thanks for sharing, this infra will be likely quite useful to me :) Cheers, Paolo