Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp909793ybe; Wed, 4 Sep 2019 09:29:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzm0yuiyK5Vhe9TfY/ZcjSjembUXLXR/hrcwM2GVck7ygHB2RbvfQeRt/Y4oD2or6ldLkDV X-Received: by 2002:a65:68d9:: with SMTP id k25mr36080795pgt.337.1567614589826; Wed, 04 Sep 2019 09:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567614589; cv=none; d=google.com; s=arc-20160816; b=ZnFoeB0KgNbv2PV8K1gB4CXyueE0XhF6+U0zplS1AkXCbkdCuUdvxtWwCDpEJrQpAB 8FLbdgw2hwUVY+jmE9wq5+x0kkO6XHfor1618v+CNCzI+LTna3vNULfeXo4PYVZlawg/ KC5XbpFj7nWayn/kbRlpgqlQLwMpcJPFxP42HsfkWV27fQdO27gySy4/iNm/Hzfykbx7 33a995GGJgujfIo/aEkwfflfIGW3A90fakguaaXwA4chzEL8VST6ebvXGxgi9X85fW1m DuDSGKvCbIgFQs8G6PYWVvjYX+aPTBQVO6AT82PdKqJuHC/wtCGpV/LUV2Bnd+Njuri5 RVQA== 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:dkim-signature; bh=Yk/Zf1u2BdMMV+kkm5yvLh1KAtBPz3BEz98OU76ZcXI=; b=Hule/0uopnWCIvA6MGMqwslLvgteQokneczzJszMJcfwW+MSK9JlCpFKz6Em743Qp9 xFQjeAD7AQBdZeSBIL3l/Qd6O1eXiKQMTGLeLzpulPIH/44IvHeRu3a59ow2MGXsvqI8 LC92qNaqKdloMDShuGNxTO/zJFci9WVvMMay7bRrQgqBDGwGuOvXtB6crp79s3J7gV3K JLkPctJvSIiNVXQZeD8g8Sp9a8/nKkgy5hBzJHDNd7rgWTmvX6r7oz28G9SidQB9R+h0 dcPBcTQEU09m4Ij1JCMlxcd/8ZNL7/ZvYqn1cwxuYPBknPJP9bCZukDQj2GWv/nGwfbi LBcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=FszKmCEw; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi3si12888582plb.423.2019.09.04.09.29.34; Wed, 04 Sep 2019 09:29:49 -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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=FszKmCEw; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731852AbfIDQ2K (ORCPT + 99 others); Wed, 4 Sep 2019 12:28:10 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:45196 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730299AbfIDQ2K (ORCPT ); Wed, 4 Sep 2019 12:28:10 -0400 Received: by mail-pf1-f195.google.com with SMTP id y72so5988124pfb.12 for ; Wed, 04 Sep 2019 09:28:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Yk/Zf1u2BdMMV+kkm5yvLh1KAtBPz3BEz98OU76ZcXI=; b=FszKmCEwYuTJXHPJSyXKFkAIkX06tgKEEJ8rXP+NANZXqsq2cuSCbfHGT0tbvOWm1W fP1DI5Nht8S23YelKpJfF72JQLn7Cw/ai1ygsPjE3Z1afhZajlZgIWlrzap+qjSOUjJv kRKicL5mPA9cDbjDOaaQv844KwyulIeQ3qAds= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Yk/Zf1u2BdMMV+kkm5yvLh1KAtBPz3BEz98OU76ZcXI=; b=JdLOYJUh2rt0LBY0OVz8u3YpwhglVOOIPQA4OWcxE4nygygWbUSaM8mtzGluo58e6f 5Z4VTp7KRuTV2ZCI3xt+cfS8GMYIFYN59MDy7ny7HnzSeTWotkwIUryTTCqpm6cjV/lI TuZCMyYSaj/lstZ371x6HuMEa4z6vHDLjZjP1o8i19GrD1L9bo5CO501uClmV7XPtAIx lGGank4m3AFjJ7tGeNFpqXJDDYbe2dLH76dc45iTz4DYjiKqRqHrOWj5B5Rwd2iILiOm L9cNO6UBWYotroI2b5u8FBL4JZ0PEo/ivDUao0Yb3DJWTRTJJJT/XgDjiKIDUFuSos4l 4g0Q== X-Gm-Message-State: APjAAAV2lrhA5MCzSoN3eAu5wTrxi5/FuTBp1AJgb7u9mwrmq36TDGEM fQUYOyPQMNEYF81+WcZlbHYYwQ== X-Received: by 2002:a17:90a:b38e:: with SMTP id e14mr5364244pjr.120.1567614489660; Wed, 04 Sep 2019 09:28:09 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id q4sm9721913pfh.115.2019.09.04.09.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 09:28:09 -0700 (PDT) Date: Wed, 4 Sep 2019 12:28:08 -0400 From: Joel Fernandes To: Michal Hocko Cc: linux-kernel@vger.kernel.org, Tim Murray , carmenjackson@google.com, mayankgupta@google.com, dancol@google.com, rostedt@goodmis.org, minchan@kernel.org, akpm@linux-foundation.org, kernel-team@android.com, "Aneesh Kumar K.V" , Dan Williams , Jerome Glisse , linux-mm@kvack.org, Matthew Wilcox , Ralph Campbell , Vlastimil Babka Subject: Re: [PATCH v2] mm: emit tracepoint when RSS changes by threshold Message-ID: <20190904162808.GO240514@google.com> References: <20190903200905.198642-1-joel@joelfernandes.org> <20190904084508.GL3838@dhcp22.suse.cz> <20190904153258.GH240514@google.com> <20190904153759.GC3838@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190904153759.GC3838@dhcp22.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 4, 2019 at 11:38 AM Michal Hocko wrote: > > On Wed 04-09-19 11:32:58, Joel Fernandes wrote: > > On Wed, Sep 04, 2019 at 10:45:08AM +0200, Michal Hocko wrote: > > > On Tue 03-09-19 16:09:05, Joel Fernandes (Google) wrote: > > > > Useful to track how RSS is changing per TGID to detect spikes in RSS and > > > > memory hogs. Several Android teams have been using this patch in various > > > > kernel trees for half a year now. Many reported to me it is really > > > > useful so I'm posting it upstream. > > > > > > > > Initial patch developed by Tim Murray. Changes I made from original patch: > > > > o Prevent any additional space consumed by mm_struct. > > > > o Keep overhead low by checking if tracing is enabled. > > > > o Add some noise reduction and lower overhead by emitting only on > > > > threshold changes. > > > > > > Does this have any pre-requisite? I do not see trace_rss_stat_enabled in > > > the Linus tree (nor in linux-next). > > > > No, this is generated automatically by the tracepoint infrastructure when a > > tracepoint is added. > > OK, I was not aware of that. > > > > Besides that why do we need batching in the first place. Does this have a > > > measurable overhead? How does it differ from any other tracepoints that we > > > have in other hotpaths (e.g. page allocator doesn't do any checks). > > > > We do need batching not only for overhead reduction, > > What is the overhead? The overhead is occasionally higher without the threshold (that is if we trace every counter change). I would classify performance benefit to be almost the same and within the noise. For memset of 1GB data: With threshold: Total time for 1GB data: 684172499 nanoseconds. Total time for 1GB data: 692379986 nanoseconds. Total time for 1GB data: 760023463 nanoseconds. Total time for 1GB data: 669291457 nanoseconds. Total time for 1GB data: 729722783 nanoseconds. Without threshold Total time for 1GB data: 722505810 nanoseconds. Total time for 1GB data: 648724292 nanoseconds. Total time for 1GB data: 643102853 nanoseconds. Total time for 1GB data: 641815282 nanoseconds. Total time for 1GB data: 828561187 nanoseconds. <-- outlier but it did happen. > > but also for reducing > > tracing noise. Flooding the traces makes it less useful for long traces and > > post-processing of traces. IOW, the overhead reduction is a bonus. > > This is not really anything special for this tracepoint though. > Basically any tracepoint in a hot path is in the same situation and I do > not see a point why each of them should really invent its own way to > throttle. Maybe there is some way to do that in the tracing subsystem > directly. I am not sure if there is a way to do this easily. Add to that, the fact that you still have to call into trace events. Why call into it at all, if you can filter in advance and have a sane filtering default? The bigger improvement with the threshold is the number of trace records are almost halved by using a threshold. The number of records went from 4.6K to 2.6K. I don't see any drawbacks with using a threshold. There is no overhead either way. For system without split RSS accounting, the reduction in number of trace records would be even higher significantly reducing the consumption of the ftrace buffer and the noise that people have to deal with. Hope you agree now? thanks, - Joel