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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 462FEC433F5 for ; Fri, 8 Apr 2022 05:00:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D21D06B0071; Fri, 8 Apr 2022 01:00:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CAACD6B0072; Fri, 8 Apr 2022 01:00:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B23F96B0074; Fri, 8 Apr 2022 01:00:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 9E14E6B0071 for ; Fri, 8 Apr 2022 01:00:57 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 7381460584 for ; Fri, 8 Apr 2022 05:00:57 +0000 (UTC) X-FDA: 79332512154.07.3F0E191 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by imf03.hostedemail.com (Postfix) with ESMTP id 0ABAB20003 for ; Fri, 8 Apr 2022 05:00:56 +0000 (UTC) Received: by mail-wr1-f48.google.com with SMTP id d3so11102453wrb.7 for ; Thu, 07 Apr 2022 22:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KEUIEi9adSNdoXW8KXtclgU3RetFXDHu8Pw4dW2isbA=; b=o7RXxtZ1cDCZRue0sRrHz1TVue0enjTGqt1HjvEk+IA8raVTONQrvfvX0FeTXqSKvX FtSzfFjcRFZtxjtFHjiRKr9z2um3s99f3Jn4Jsb9WAydhWNJHdtJM7igBo8PjX7H3Rjf mqqkKxr+7KexBHf3vNHS9f0qPUmgY37p2YUyp6/AflZqY2NsKxUitAvgrFQyRqvJQyc5 KmKCzAK9duyoWb5HnTL7/rqzXKXmJFmeqhaGPBh4Z/8PXETA2bYyWEL3YDL6NLNSN2z3 kMv5ynQ4wZtEKiYYloH6n1Z8y/rIw4HEW4YYgpLXpX24QberMRKQ3RVbD3QPsFyyd6Ym K6og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KEUIEi9adSNdoXW8KXtclgU3RetFXDHu8Pw4dW2isbA=; b=cShajnhKnQMrp8Tw8KocduUiwb+kDKAuC9v9LElE3vCqvbkB0GetRM07avUyD2jw5j /qDoOzB612kkHNP5K4O9UcfRQbO5I/VJfy7pZNjv1BDL2TyiLGc4nOCHb1h53VfVXsqm n47nqVj8FSuRCXRnoydCaHWIV+WWOBiwgivbSVMtLO70c9EJT6P9Bl1ZNvj8OkJaZrqE Xam78JysDukItxfoh46rEP+eRUzUzD22DQ34DhqLpcDLiiTmuT9Cvl+Wqab+Gjy8CDyc w3FUPCQX5YoCljgjLTlplORxUyzQXEhuIcLyTxkKSkxzypTn6xkvcxHkDz0BPbIAoQbz 2Hhg== X-Gm-Message-State: AOAM531KNte3EdoMoUJC6Sq/dP7NkTMLqUPM6dHhx4lL0N4YCUQ/LGsJ +Vabk6rmDi80jnznPFWMydjxwjds2l7pJdGO1FFn7w== X-Google-Smtp-Source: ABdhPJx8gwwFGKo9JHFub9Glw4ixcEqLNimwl5VmXqky+27dSQgR/DF9ZrdodFvPPP+gdnMxF2HiStZfvRzIoAASGEo= X-Received: by 2002:adf:8066:0:b0:206:1563:8b2b with SMTP id 93-20020adf8066000000b0020615638b2bmr13333325wrk.582.1649394055492; Thu, 07 Apr 2022 22:00:55 -0700 (PDT) MIME-Version: 1.0 References: <20220407224244.1374102-1-yosryahmed@google.com> <20220407224244.1374102-4-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Thu, 7 Apr 2022 22:00:07 -0700 Message-ID: Subject: Re: [PATCH v2 3/4] selftests: cgroup: fix alloc_anon_noexit() instantly freeing memory To: Andrew Morton Cc: David Rientjes , Tejun Heo , Zefan Li , Jonathan Corbet , Shuah Khan , Yu Zhao , Dave Hansen , Wei Xu , Greg Thelen , Chen Wandun , Vaibhav Jain , Johannes Weiner , Huang@google.com, Ying , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Tim Chen , cgroups@vger.kernel.org, linux-doc@vger.kernel.org, Linux Kernel Mailing List , Linux-MM , linux-kselftest@vger.kernel.org, Michal Hocko , Shakeel Butt , Roman Gushchin Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=o7RXxtZ1; spf=pass (imf03.hostedemail.com: domain of yosryahmed@google.com designates 209.85.221.48 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 946gdgt689wzs9gp8o4zqswhhertarq8 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0ABAB20003 X-HE-Tag: 1649394056-125541 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 Thu, Apr 7, 2022 at 4:04 PM Yosry Ahmed wrote: > > On Thu, Apr 7, 2022 at 3:43 PM Yosry Ahmed wrote: > > > > Currently, alloc_anon_noexit() calls alloc_anon() which instantly frees > > the allocated memory. alloc_anon_noexit() is usually used with > > cg_run_nowait() to run a process in the background that allocates > > memory. It makes sense for the background process to keep the memory > > allocated and not instantly free it (otherwise there is no point of > > running it in the background). > > > > Signed-off-by: Yosry Ahmed > > --- > > tools/testing/selftests/cgroup/test_memcontrol.c | 9 +++++++-- > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c > > index 36ccf2322e21..c1ec71d83af7 100644 > > --- a/tools/testing/selftests/cgroup/test_memcontrol.c > > +++ b/tools/testing/selftests/cgroup/test_memcontrol.c > > @@ -211,13 +211,18 @@ static int alloc_pagecache_50M_noexit(const char *cgroup, void *arg) > > static int alloc_anon_noexit(const char *cgroup, void *arg) > > { > > int ppid = getppid(); > > + size_t size = (unsigned long)arg; > > + char *buf, *ptr; > > > > - if (alloc_anon(cgroup, arg)) > > - return -1; > > + buf = malloc(size); > > + for (ptr = buf; ptr < buf + size; ptr += PAGE_SIZE) > > + *ptr = 0; > > > > while (getppid() == ppid) > > sleep(1); > > > > + printf("Freeing buffer"); > > Hey Andew, > > I am very sorry but I left a debugging printf there by mistake. If > it's no hassle, do you mind removing it from the patch (assuming I > won't need to send a v3 anyway)? Never mind I already sent v3 and removed it with other fixes. > > Thanks! > > > + free(buf); > > return 0; > > } > > > > -- > > 2.35.1.1178.g4f1659d476-goog > >