Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1236304pxk; Mon, 31 Aug 2020 13:41:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIfdV5hvzax1Xhx0QqrWFxEW7zbm0vYdw/JylcPw1CucXSQwvGqWlWgJK/eIMVjxI7TlWr X-Received: by 2002:a50:b2a5:: with SMTP id p34mr2816758edd.385.1598906488607; Mon, 31 Aug 2020 13:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598906488; cv=none; d=google.com; s=arc-20160816; b=bSx2R+WfvvN/3811ecLEQmuXhBtK2+oJvGd0DagcuYu3htukjHyP6sPiQ3DE4LCPyp Q4G5Uo8y7rY63AmTBQ5Gy7x5afJ6t7ilJtZ62dwNQnimo2itUPG2VKwOnpaCbWD8k/0r x7Zqrqq3D0j7xWPCHhFrDJRMXJPl3DWtwJvE6Bsdq5w9UXs7HDo7eD0uef64S9GsSs6z eC7spPYGPL+8AkqPFWoAWOMTFb+2+pId3Z4TEhqj+zsE/qkvDIJPXjgate9hOarwK+2U j3Ngh1nNSg3OQ50xHonlYseyQKtsfWhTQdCCoWrQ7f6EKlHX1Y4crT7sL8Er29HjOqLA I3bg== 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=PZdD3YkccjOVfF0atuAqD6nWNa6V5XxvIiUqs3VdtEk=; b=PaP7Twefuh/J1+kD3rb3FSgFJtTrNkxxK/3svHFV/v6y3CQt+IursdwsSg40PKk1Oc 8qPb3anEwYEN4R6HT0yUIlrvcDn/LnYlmqsaxBIB36Tdcu2ZaCx5y+vNwlPe1t3Ojth9 1JtvZkYy9/CEu3SINhhAjcIsWs9SnUtCaykMDNLQmGp2z5leCoYsUZgn82OhUbiU4XUs zzqCPaXJa48qOn7h7cBECd3OofVPZhxcHUKBVlaMQIOMk/Cck9Lr60agJvVJfB3Xh5eJ eFj0UgDu9kBQ+ziwNrvcBFrnvMcLckl9zda6uyK4tipe6Y+LsBTqIKj6H82aMKtJYhG/ zOIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DTYm1SPd; 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 x10si5746834ejv.339.2020.08.31.13.41.05; Mon, 31 Aug 2020 13:41:28 -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=DTYm1SPd; 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 S1729044AbgHaSI5 (ORCPT + 99 others); Mon, 31 Aug 2020 14:08:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729118AbgHaSIz (ORCPT ); Mon, 31 Aug 2020 14:08:55 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6D3DC061575 for ; Mon, 31 Aug 2020 11:08:52 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id a65so365743wme.5 for ; Mon, 31 Aug 2020 11:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PZdD3YkccjOVfF0atuAqD6nWNa6V5XxvIiUqs3VdtEk=; b=DTYm1SPdGKG/SQtAldlYoFxpYjZpsl532qhv6HisDz50C8zjjFhEV6VYZYr/ZbT+YP 2dXuN0EArHJmyGH6Jkl1c2ql7cfM6UVizHL24w3vkUBubm2HJ1ct3QMJd4kMU+UAVlHj rzaGTYp0oZXldmNTj8Xb7CpfnTFyYvOqXZwRhFpuLeLTYyTVHZ+rW4/+UFwZOpE7hyS+ 31QOuY6UA00D7IURmMft9i+6WOx45GT/92Dl5UWgoNNppyhJ5XehPXy1wPMLE35Nh8wK oiaMu8ZQSo01pCgeXrJAF+WAOxurJw9Tn+Vk7feQaXuBsocQYSjm60tLNh0K/bP3rKhW MxOA== 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=PZdD3YkccjOVfF0atuAqD6nWNa6V5XxvIiUqs3VdtEk=; b=VrOrYD3Biqnj02R7SLcy3AgzdwiZ82AJGR21AHCZjhBDoYVsjO6jwKcqEtNgqCZPPy M3MK8+6xxEL2d9SH7rUd+0SrixS7wlIxEPI0keOVMrqhHSNHYBLKYxPetxlpkTdxXIVi m3qq1BPUe8rm80hSy24/is+kTZIkGvd7qXWzGfhEi1GmVwXyuXQfUtJWtAIycfhWx7aH Ga+vVAXeOz9JlucxjyvvMsrq/yo+8n8rRbbChDvLxv/b4IjraRzE3btUnelB0/rV5D6J DhNu6CsDOfVFaE/hRGp6P6s0bhoZiUwrHb0a/cU1cH5y08+Qo3lqZDHsFyBYbDU8FJbb wSvQ== X-Gm-Message-State: AOAM5323PxhAme0hBf7MXJHYCnqYO4XVy3+uX8pYPQ20tzZdOoMr3WMk FHGCV4wlZKcT5PQrbXBORE1B9w== X-Received: by 2002:a05:600c:22d6:: with SMTP id 22mr501445wmg.120.1598897331339; Mon, 31 Aug 2020 11:08:51 -0700 (PDT) Received: from elver.google.com ([100.105.32.75]) by smtp.gmail.com with ESMTPSA id e18sm12975638wrx.50.2020.08.31.11.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 11:08:50 -0700 (PDT) Date: Mon, 31 Aug 2020 20:08:44 +0200 From: Marco Elver To: SeongJae Park Cc: akpm@linux-foundation.org, SeongJae Park , Jonathan.Cameron@Huawei.com, aarcange@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, amit@kernel.org, benh@kernel.crashing.org, brendan.d.gregg@gmail.com, brendanhiggins@google.com, cai@lca.pw, colin.king@canonical.com, corbet@lwn.net, david@redhat.com, dwmw@amazon.com, fan.du@intel.com, foersleo@amazon.de, gthelen@google.com, irogers@google.com, jolsa@redhat.com, kirill@shutemov.name, mark.rutland@arm.com, mgorman@suse.de, minchan@kernel.org, mingo@redhat.com, namhyung@kernel.org, peterz@infradead.org, rdunlap@infradead.org, riel@surriel.com, rientjes@google.com, rostedt@goodmis.org, rppt@kernel.org, sblbir@amazon.com, shakeelb@google.com, shuah@kernel.org, sj38.park@gmail.com, snu@amazon.de, vbabka@suse.cz, vdavydov.dev@gmail.com, yang.shi@linux.alibaba.com, ying.huang@intel.com, zgf574564920@gmail.com, linux-damon@amazon.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC v8 01/10] mm/damon/debugfs: Allow users to set initial monitoring target regions Message-ID: <20200831180844.GA3992970@elver.google.com> References: <20200831104730.28970-1-sjpark@amazon.com> <20200831104730.28970-2-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200831104730.28970-2-sjpark@amazon.com> User-Agent: Mutt/1.14.4 (2020-06-18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 31, 2020 at 12:47PM +0200, SeongJae Park wrote: [...] > diff --git a/mm/damon.c b/mm/damon.c > index 7e3c8c82a010..9815d22fc4de 100644 > --- a/mm/damon.c > +++ b/mm/damon.c > @@ -2001,6 +2001,147 @@ static ssize_t debugfs_record_write(struct file *file, > return ret; > } > > +static ssize_t sprint_init_regions(struct damon_ctx *c, char *buf, ssize_t len) > +{ > + struct damon_target *t; > + struct damon_region *r; > + int written = 0; > + int rc; > + > + damon_for_each_target(t, c) { > + damon_for_each_region(r, t) { > + rc = snprintf(&buf[written], len - written, > + "%lu %lu %lu\n", > + t->id, r->ar.start, r->ar.end); This most likely will not work as intended, because snprintf() returns "[...] the number of characters which would be generated for the given input, excluding the trailing null [...]". Would scnprintf() -- which returns "[...] the number of characters written into @buf not including the trailing '\0' [...]" -- do what you intended? > + if (!rc) > + return -ENOMEM; > + written += rc; > + } > + } > + return written; > +} [...]