Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2020802imm; Tue, 10 Jul 2018 11:44:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeLxozKZBzVIRt2qY674dUgKrFYM0fGWeqO7zGC84bdWc5Oy+vnkLY0UCihJBHMHYmMfx9G X-Received: by 2002:a62:4141:: with SMTP id o62-v6mr26692971pfa.111.1531248285441; Tue, 10 Jul 2018 11:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531248285; cv=none; d=google.com; s=arc-20160816; b=xazvuEz3VTGO9Mt1uvq3Hd3/mnQH/GRP2e1iljd/WXCO7rItuI4hbcUywbB52pn/+P 6vacp2PUaCNXnVGmKskNiNN7+jAkJtwYmUWVRWnOvAWmy9beycaaIH9NqVyBRrA1YAz+ W5fgIW8YiE1d4Ia/9TUhNP0CfNO9eJnHdCnsuA0PL8PldyJN2dTIkpKFbW7ouKI2NvOY teqVNk0PLzRqYGzHQjXd9n9zL4PJy19GZFfT2CECmwilEURku95sm4lgijbLjEN0NPDS Tzj39ce/W/uUr46oEgtHHYHNvyqBXBGuEtaeMHhfesQeJV9gx9Au/3Q39JVqblprl2xZ 8RCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=3At2HdVabI3g7tPQjqYYwJcDHynKJqsOH50gLPVzb18=; b=XY5MPH3fpMOgoOrk3ADqDNmunFegd7ErIZWdksDnOs/FD2h0tKNLuqkM7nERnnPyIf izWDyJv7TffPJ5iI4T+NGxntVON/vfz3TP/UrI/VfP7OahgYM0ffwW+uZLSGpO6TIv/v IufCOosKWUYTPQnDVhusAccIF7+nYo/0F9f3qyg3ObAs+R1kOBbHjfVqrj7dY9aC1xxV CYBejQr/S+ohsLQelOP8yV5Hjs+0TqE715m/qKvcLcf1L+U0W2KdFHQp7iQ463dczGgc x8bUWqc14BX9rP8wQnm5pmUirYgWRVRz6w+q4R4YJqaLKkYMo4gHIo/mJF1s2vi4Q0cz qaYQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5-v6si17135034pgl.516.2018.07.10.11.44.30; Tue, 10 Jul 2018 11:44:45 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389110AbeGJSd7 (ORCPT + 99 others); Tue, 10 Jul 2018 14:33:59 -0400 Received: from mga05.intel.com ([192.55.52.43]:10774 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388051AbeGJSd6 (ORCPT ); Tue, 10 Jul 2018 14:33:58 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2018 11:33:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,335,1526367600"; d="scan'208";a="55491032" Received: from ssarabia-mobl7.amr.corp.intel.com ([10.254.80.171]) by orsmga007.jf.intel.com with ESMTP; 10 Jul 2018 11:33:40 -0700 Date: Tue, 10 Jul 2018 11:33:39 -0700 From: Solio Sarabia To: linux-kernel@vger.kernel.org, ak@linux.intel.com, stephen@networkplumber.org Cc: linux-perf-users@vger.kernel.org, kys@microsoft.com, amy.l.leeland@intel.com, shiny.sebastian@intel.com, solio.sarabia@intel.com Subject: Re: Differences in cpu utilization reported by sar, emon Message-ID: <20180710183339.GA3796@ssarabia-MOBL7.amr.corp.intel.com> References: <20180615034133.GA5932@ssarabia-MOBL7.amr.corp.intel.com> <20180620234140.GA13040@ssarabia-MOBL7.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180620234140.GA13040@ssarabia-MOBL7.amr.corp.intel.com> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Further analysis shows that even with CONFIG_IRQ_TIME_ACCOUNTING or DYNTICKS (CONFIG_VIRT_CPU_ACCOUNTING_GEN) there are some CPU cycles lost. This difference correlates with the number of interrupts/sec handled in the core, as the number increases, difference also does. Network example (linux baremetal): sar emon emon-sar interrupts/sec core18 19.2 20.9 1.7 11057 core21 25.1 30.5 5.4 31472 core27 18.3 20.1 1.8 10384 core30 5.6 11.4 5.8 35841 core34 17.8 20.5 2.7 10973 Storage example (fio, device attached directly to vm): sar perfmon emon-perfmon interrupts/sec core10 7.4 19.7 12.3 100481 In the storage case, up to 12% irq cycles were not accounted. As users start adopting more capable SSDs for instance, the issue will be more evident. I would like to understand the reason as to why this happens: What could be the reason for this issue? Any pointers to the kernel subsystem/code performing time accounting? Thanks, -Solio On Wed, Jun 20, 2018 at 04:41:40PM -0700, Solio Sarabia wrote: > Thanks Andi, Stephen, for your help/insights. > > TICK_CPU_ACCOUNTING (default option) does not account for cpu util on > cores handling irqs and softriqs. > > IRQ_TIME_ACCOUNTING or VIRT_CPU_ACCOUTING_GEN helps to reduce the util > gap. With either option, there is still a difference, for example, up to > 8% in terms of sar/emon ratio (sar shows lesser util). This is an > improvement to the default case though. > > > This is a brief description of the Kbuild options: > > -> General setup > -> CPU/Task time and stats accounting > -> Cputime accounting > TICK_CPU_ACCOUNTING > Simple/basic tick based cpu accounting--maintains statistics about > user, system and idle time spent on per jiffies granularity. > VIRT_CPU_ACCOUNTING_NATIVE (not available on my kernel) > Deterministic task and cpu time accounting--more accurate task > and cpu time accounting. Kernel reads a cpu counter on each kernel > entry and exit, and on transitions within the kernel between > system, softirq, and hardirq state, so there is a small performance > impact. > VIRT_CPU_ACCOUTING_GEN > Full dynticks cpu time accounting--enable task and cpu time > accounting on full dynticks systems. Kernel watches every > kernel-user boundaries using the context tracking subsystem. > There is significant overhead. For now only useful if you are > working on the full dynticks subsystem development. > IRQ_TIME_ACCOUNTING > Fine granularity task level irq time accounting--kernel reads a > timestamp on each transition between softirq and hardirq state, > so there can be a performance impact. > > -Solio > > > On Thu, Jun 14, 2018 at 08:41:33PM -0700, Solio Sarabia wrote: > > Hello -- > > > > I'm running into an issue where sar, mpstat, top, and other tools show > > less cpu utilization compared to emon [1]. Sar uses /proc/stat as its > > source, and was configured to collect in 1s intervals. Emon reads > > hardware counter MSRs in the PMU in timer intervals, 0.1s for this > > scenario. > > > > The platform is based on Xeon E5-2699 v3 (Haswell) 2.3GHz, 2_sockets, > > 18_cores/socket, 36_cores in total, running Ubuntu 16.04, Linux > > 4.4.0-128-generic. A network micro workload, ntttcp-for-linux [2], > > sends packets from client to server, through a 40GbE direct link. > > Numbers below are from server side. > > > > total %util > > CPU11 CPU21 CPU22 CPU25 > > emon 99.99 15.90 36.22 36.82 > > sar 99.99 0.06 0.36 0.35 > > > > interrupts/sec > > CPU11 CPU21 CPU22 CPU25 > > intrs/sec 846 28923 12844 6304 > > Contributors to /proc/interrupts: > > CPU11: Local timer interrupts and Rescheduling interrupts > > CPU21-CPU25: PCI MSI vector from network driver > > > > softirqs/sec > > CPU11 CPU21 CPU22 CPU25 > > TIMER 198 1 2 1 > > NET_RX 1 28889 23553 18546 > > TASKLET 0 28889 11676 6249 > > > > > > Somehow hardware irqs and softirqs do not have an effect on the core's > > utilization. Another observation is that as more cores are used to > > process packets, the emon/sar gap increases. > > > > Kernels used default HZ=250. I also tried HZ=1000, which helped improve > > throughput, but difference in util is still there. Same for newer > > kernels 4.13, 4.15. I would appreciate pointers to debug this, or > > insights as what could cause this behavior. > > > > [1] https://software.intel.com/en-us/download/emon-users-guide > > [2] https://github.com/simonxiaoss/ntttcp-for-linux > > > > Thanks, > > -Solio