Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1505157pxk; Mon, 31 Aug 2020 23:38:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjgSdIfbg2w4GK6r6SMspip2fHqlR+y4drvHTlsD3I58arElFMFyccF3iMHF12e7XoqOg9 X-Received: by 2002:aa7:c70a:: with SMTP id i10mr477025edq.218.1598942281876; Mon, 31 Aug 2020 23:38:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598942281; cv=none; d=google.com; s=arc-20160816; b=rMvcG+wEEu3R/3DoH1pmJ+1fJxhfkYXViEA2WiTbUhAy+jYq+4DxLjyyerFKOMKZQD eCiO5iLw7mUBQZOaVrVM4Ixdf1TUcY6tgomZ4nYMlglSW2EhnGGDPWrLejSFZTugNCRE w9bpEC76hWlZhiNXRgASc9BXuxyFD1VqRlX6sunLI/YaaA69TnmoYNWsReDKzCJfjOXG U0HBdC8XAzvMzmSw6OMSKhJd1tMlzsaE568HyldSCj8A3rGQRy+q0ff7sBImbcIElLGZ DnU6kIiMV1I17ub8QgaPX4rRjOPKXegsxICmF2VUfmlTDGZtkhWapurq8woDY1wMXarA 8QAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=sJPzQ3w3NJGcVjvcL8Xgt43HqNctNK4Z1JUvgEcgB8Q=; b=YpBlkMonbJZxxhVf5Y/7QnZHHQ3NkJ3Us3Ddd+/n1CYyrhQk8eJt7vsrgm1oaAasHU 6RtqPam8nXKAQ696jZD9fYgknrzCqGNRPLgRmEkWOD28aNCsY8e9zrH85zsAISympqBU DEHRzi8TDiERcgSWL/Q6paDKrB7qHWZyB39rpq5ctFGwIY2hUqQaZl917lWK9DSx3WYb Xi/yYzJmp3zQSKGaWG/Hf7CUKkvTe+XojhFWuCA/43mcO5C7V57HrOAxnGf5dQbEFz4R JF2x/jnnVNJukvjZHV5q13Dasgbpyhe91CR5p93Fy28l7ZlpraJP5OZYSzz1/LUkZDh3 zSCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=O6gR6NH0; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qx20si165390ejb.469.2020.08.31.23.37.39; Mon, 31 Aug 2020 23:38:01 -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=@amazon.com header.s=amazon201209 header.b=O6gR6NH0; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726586AbgIAGgc (ORCPT + 99 others); Tue, 1 Sep 2020 02:36:32 -0400 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:20656 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbgIAGgb (ORCPT ); Tue, 1 Sep 2020 02:36:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1598942191; x=1630478191; h=from:to:cc:subject:date:message-id:in-reply-to: mime-version; bh=sJPzQ3w3NJGcVjvcL8Xgt43HqNctNK4Z1JUvgEcgB8Q=; b=O6gR6NH0p4ABVuqjZwZ7eiydXwYv67WqCd5pDLtVe2cw8f4CRMxKK6C7 eux0elqjgv737XcbLgMhGulMhx2j2SGO1Ad1VXVACOcfWYSzPc5+bfWUn FDIk68+MHSxLJIIEBzx4QhptcA4Se48EPrkMxZ4Lo317f1+uEd5gJYDVV A=; X-IronPort-AV: E=Sophos;i="5.76,378,1592870400"; d="scan'208";a="52696113" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-af6a10df.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 01 Sep 2020 06:36:29 +0000 Received: from EX13D31EUA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-af6a10df.us-east-1.amazon.com (Postfix) with ESMTPS id BEEC4A2394; Tue, 1 Sep 2020 06:36:17 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.160.100) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 1 Sep 2020 06:35:59 +0000 From: SeongJae Park To: Marco Elver CC: SeongJae Park , , "SeongJae Park" , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [RFC v8 01/10] mm/damon/debugfs: Allow users to set initial monitoring target regions Date: Tue, 1 Sep 2020 08:35:42 +0200 Message-ID: <20200901063542.1290-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200831180844.GA3992970@elver.google.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.160.100] X-ClientProxiedBy: EX13D20UWA001.ant.amazon.com (10.43.160.34) To EX13D31EUA001.ant.amazon.com (10.43.165.15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 31 Aug 2020 20:08:44 +0200 Marco Elver wrote: > 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? Ah, you're right! I will use 'scnprintf' instead, not only here but in other relevant parts. Thanks, SeongJae Park > > > + if (!rc) > > + return -ENOMEM; > > + written += rc; > > + } > > + } > > + return written; > > +} > [...]