Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp544177ybe; Fri, 6 Sep 2019 03:34:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxD5SAZUq/lhTlqACcBEWEaQrkouJWaukY8gRX/yOqll4/oLHIGkE6rf81ab/a6ZI3JNi1A X-Received: by 2002:a17:902:ba89:: with SMTP id k9mr5956146pls.44.1567766097984; Fri, 06 Sep 2019 03:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567766097; cv=none; d=google.com; s=arc-20160816; b=r/bKgbJYN12BIx9lhIsrIO2LF5ynxYzWkra3k7L4M4VEIaqJJQeQrhjPEpPTwdXh8s v7ZlT9vINkAW6Ef0CfRB9+BxcBCmpWEdOSWddPPDur62ys7LtjmrOjtQuJ9qsD9M1a5b 9fKO454Q5ByK2JxQoe7pok/t/nHDjbl3hPLUSuP3KV5FwU9KOs0KA/b4sdg+50wFisKV HdWwvchicL96OkZWfvfSn4c2RQ2MpjaASZ/3WruTfdUILCA3x9eAdbbVmwytlZSas1md AKF9HWwGmuarhjk7W06bvdSjUC9wHAJGba6UIbg2SiKciGJenbENRHNeKy+Ec9buWDR/ D53A== 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=VdtQHcHlOGfkgdoayOFupO26wYojQPptWdBT4QWZFV0=; b=ewI1Jq3KqzeMaHyWSv1s+J/FJOzfn55kcFr8BvYFHdyIt4/7eNI9nKzYzn3D5AEjnq KqYqPUGfIIQDYUnuoJMLPsiFis/soJ576jwEves5Pof5Bsi58F8OTTDMD35cZ6luotla AyXElVAsv7hPrLRCxw5HqnggWLOjwoWzq9OChTE+8UKZdzUXX7Aji/2nl4Sl/iaEfr6p dPPBecfREdm6CDqhQR0Z2Xl10k6cX/r0ZAaJPZ8tHs1gNgobFt6vZOEDGLot1F9x4eTB +lvsMIh3LpaMsnqKgGZGOOT+gRNKz/hB0QEbnungvJxztiQrSDNc++jkMlZHMtNEjpkW kttA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=qKDIxdaB; 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 b190si4176761pga.105.2019.09.06.03.34.41; Fri, 06 Sep 2019 03:34:57 -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=qKDIxdaB; 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 S2392072AbfIFDBr (ORCPT + 99 others); Thu, 5 Sep 2019 23:01:47 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45206 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731491AbfIFDBp (ORCPT ); Thu, 5 Sep 2019 23:01:45 -0400 Received: by mail-pl1-f193.google.com with SMTP id x3so2355305plr.12 for ; Thu, 05 Sep 2019 20:01:44 -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=VdtQHcHlOGfkgdoayOFupO26wYojQPptWdBT4QWZFV0=; b=qKDIxdaBOcENAQEPhYaySH0B5SQARhQhLC6br1u55nJm0eVwYM8SSQVmlFoHirjoub Q0JZknIUZ1KihMnJ+Y/QiW6S2D06im9oRco+h+YsqTvdg8pxq+y8iCrMrDOEZEZbIxig Ngr6Lv3il76BZi2EFjjXczMgUa5KVU0HK757M= 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=VdtQHcHlOGfkgdoayOFupO26wYojQPptWdBT4QWZFV0=; b=GveE7ji/S0GKpE4fQWoBe+UtYRfsKvnqyBthqB8B7wxVGnM4pXvGf2ki9EXqhIXwcY IGaPiNxRVtlF5im4x5wbHxENaRHhdiHu5mbUReH689p0XPSsta1M0Hu49KthZdxXV1c7 Vb+kwJs03YUiWFdBjgr8+h92a8ap0NKcNAhFPOBDP8uDE9+Cgp4k9nNGP15uKtTRkNeX I4RyOqnkMgsiiFKPkB8me5j2nIsH7zsYbZXwXVf06/TqWcNBlwhFIzrb3FovybaduBXt aML12E6Ipfh+q1Vg9hypiEbKKoLQIJOoekDVVbdmAPYScvYa6jsg0YIoWSHjyiZSAIFU WrSQ== X-Gm-Message-State: APjAAAUE9zDXXbX3tzdMyFrlq0ndCAiIxVy9//32F+W0WOUlWvrv7ZOt EjOWAO/lUA4cpM4XKnH7Hi1G5w== X-Received: by 2002:a17:902:bc4c:: with SMTP id t12mr6912147plz.90.1567738904014; Thu, 05 Sep 2019 20:01:44 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id d135sm4364879pfd.81.2019.09.05.20.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 20:01:43 -0700 (PDT) Date: Thu, 5 Sep 2019 23:01:42 -0400 From: Joel Fernandes To: Daniel Colascione Cc: Steven Rostedt , Suren Baghdasaryan , Michal Hocko , LKML , Tim Murray , Carmen Jackson , Mayank Gupta , Minchan Kim , Andrew Morton , kernel-team , "Aneesh Kumar K.V" , Dan Williams , Jerome Glisse , linux-mm , Matthew Wilcox , Ralph Campbell , Vlastimil Babka , Tom Zanussi Subject: Re: [PATCH v2] mm: emit tracepoint when RSS changes by threshold Message-ID: <20190906030142.GA29926@google.com> References: <20190904084508.GL3838@dhcp22.suse.cz> <20190904153258.GH240514@google.com> <20190904153759.GC3838@dhcp22.suse.cz> <20190904162808.GO240514@google.com> <20190905144310.GA14491@dhcp22.suse.cz> <20190905133507.783c6c61@oasis.local.home> <20190906005904.GC224720@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Sep 05, 2019 at 06:15:43PM -0700, Daniel Colascione wrote: [snip] > > > > > > > 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. > > > > > > > > > > > > Steven, would it be feasible to add a generic tracepoint throttling? > > > > > > > > > > I might misunderstand this but is the issue here actually throttling > > > > > of the sheer number of trace records or tracing large enough changes > > > > > to RSS that user might care about? Small changes happen all the time > > > > > but we are likely not interested in those. Surely we could postprocess > > > > > the traces to extract changes large enough to be interesting but why > > > > > capture uninteresting information in the first place? IOW the > > > > > throttling here should be based not on the time between traces but on > > > > > the amount of change of the traced signal. Maybe a generic facility > > > > > like that would be a good idea? > > > > > > > > You mean like add a trigger (or filter) that only traces if a field has > > > > changed since the last time the trace was hit? Hmm, I think we could > > > > possibly do that. Perhaps even now with histogram triggers? > > > > > > I was thinking along the same lines. The histogram subsystem seems > > > like a very good fit here. Histogram triggers already let users talk > > > about specific fields of trace events, aggregate them in configurable > > > ways, and (importantly, IMHO) create synthetic new trace events that > > > the kernel emits under configurable conditions. > > > > Hmm, I think this tracing feature will be a good idea. But in order not to > > gate this patch, can we agree on keeping a temporary threshold for this > > patch? Once such idea is implemented in trace subsystem, then we can remove > > the temporary filter. > > > > As Tim said, we don't want our traces flooded and this is a very useful > > tracepoint as proven in our internal usage at Android. The threshold filter > > is just few lines of code. > > I'm not sure the threshold filtering code you've added does the right > thing: we don't keep state, so if a counter constantly flips between > one "side" of the TRACE_MM_COUNTER_THRESHOLD and the other, we'll emit > ftrace events at high frequency. More generally, this filtering > couples the rate of counter logging to the *value* of the counter --- > that is, we log ftrace events at different times depending on how much > memory we happen to have used --- and that's not ideal from a > predictability POV. > > All things being equal, I'd prefer that we get things upstream as fast > as possible. But in this case, I'd rather wait for a general-purpose > filtering facility (whether that facility is based on histogram, eBPF, > or something else) rather than hardcode one particular fixed filtering > strategy (which might be suboptimal) for one particular kind of event. > Is there some special urgency here? > > How about we instead add non-filtered tracepoints for the mm counters? > These tracepoints will still be free when turned off. > > Having added the basic tracepoints, we can discuss separately how to > do the rate limiting. Maybe instead of providing direct support for > the algorithm that I described above, we can just use a BPF program as > a yes/no predicate for whether to log to ftrace. That'd get us to the > same place as this patch, but more flexibly, right? Chatted with Daniel offline, we agreed on removing the threshold -- which Michal also wants to be that way. So I'll be resubmitting this patch with the threshold removed; and we'll work on seeing to use filtering through other generic ways like BPF. thanks all! - Joel