From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B5EBC433E7 for ; Tue, 1 Sep 2020 06:36:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0C81A215A4 for ; Tue, 1 Sep 2020 06:36:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="O6gR6NH0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C81A215A4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9D3718E0001; Tue, 1 Sep 2020 02:36:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 983CE6B005D; Tue, 1 Sep 2020 02:36:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 871C38E0001; Tue, 1 Sep 2020 02:36:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0052.hostedemail.com [216.40.44.52]) by kanga.kvack.org (Postfix) with ESMTP id 7189F6B005C for ; Tue, 1 Sep 2020 02:36:31 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3B6BF362A for ; Tue, 1 Sep 2020 06:36:31 +0000 (UTC) X-FDA: 77213533782.24.shade70_020f39227096 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 14ECC1A4A5 for ; Tue, 1 Sep 2020 06:36:31 +0000 (UTC) X-HE-Tag: shade70_020f39227096 X-Filterd-Recvd-Size: 4512 Received: from smtp-fw-6001.amazon.com (smtp-fw-6001.amazon.com [52.95.48.154]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Tue, 1 Sep 2020 06:36:30 +0000 (UTC) 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) X-Rspamd-Queue-Id: 14ECC1A4A5 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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; > > +} > [...]