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=-13.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no 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 5CEB2C11F68 for ; Wed, 30 Jun 2021 19:01:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DF25561444 for ; Wed, 30 Jun 2021 19:01:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF25561444 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 215BC8D01C1; Wed, 30 Jun 2021 15:01:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C5F18D01A2; Wed, 30 Jun 2021 15:01:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 066AF8D01C1; Wed, 30 Jun 2021 15:01:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id D83328D01A2 for ; Wed, 30 Jun 2021 15:01:52 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A976F25F34 for ; Wed, 30 Jun 2021 19:01:52 +0000 (UTC) X-FDA: 78311309664.10.7279513 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by imf26.hostedemail.com (Postfix) with ESMTP id 5815D2001709 for ; Wed, 30 Jun 2021 19:00:52 +0000 (UTC) Received: by mail-lf1-f42.google.com with SMTP id n14so7008651lfu.8 for ; Wed, 30 Jun 2021 12:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AEgh9Jy+v2hf9QQxXrhqFRUWrnkAgTuVo3us79cOIOw=; b=ZKBY6VftutgEegz48judWjWXy81U7xX6OZgRzr3GXzWpadR6jP1iqlLNU7Y0d91WTG Beq8K5ZKgeKbUwLlCcz/aYP37Gj8UvZH42R94ZAq7P0Rc43sFsmak+4n6NY8UGlVWZBt DDCSUjd/HrmFRtzM5nWojlT5UF+iBDUCSRMJq5cbRi+d4m93TcHPHdB6yHVlIV8p8Ko6 Qj0HTt7jrncgZ4ntXM0Xazu8x5iwm77s+HJe7YvmCAJFyZcNXez8Oez4IdvPIMf/M9tw bLbErz1qi1vxtLpvIBXoPpc5K9bdOU+yS/Ifv/UG3pA9BpwzpqV+e1vd5kSLvUmOWBe5 AnnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AEgh9Jy+v2hf9QQxXrhqFRUWrnkAgTuVo3us79cOIOw=; b=b1eVPwv9aNNKc11OZU/TizFMv4B3Oja4i2sffAcSwa8yC5kOsFLyBA3qmW8fwqX4/h kdWy1LYB0qpVaBZn2s9AYG3XcBznEWpNemmaoKSgCKDeNf7OI7X9XPPRVXYmKRldl9Y7 2PB/jJoNgOnNKLAWn+dMBnCVtwXgFZkrvvXtfofO5oO73TSUN6fQoOvi66FsLERPpJ1N EGzaEv2L2ATsS7eo5oSlhR3scJAYprpnLkNte7xNLBPvQRk9YBbqCNu68mXN30jyGlhD MMVV0omqaVdeuhUBVNeZ6Q8bUviI/s+9QAWH0xZ2USOXSawtvQVWvhvyBv7B0QQY4hLf G4KQ== X-Gm-Message-State: AOAM532ihNpju6dcYraQaxfolxfTOGP56lHTbb/KCKQ5rcwjd4rNOKNX /YLDa7Vcs72R2M5X0WWqxPMFB1cNK1wnIO/7jeXHFQ== X-Google-Smtp-Source: ABdhPJzDjoniOT1Bd7VA+hYgwG7DePFjKijlt9GhP+NN1iQALNtamNNzBBHpZmLXaQL0UebX9WZd5/yC9rRoLL/gt2g= X-Received: by 2002:a05:6512:442:: with SMTP id y2mr27208904lfk.117.1625079650220; Wed, 30 Jun 2021 12:00:50 -0700 (PDT) MIME-Version: 1.0 References: <20210623192822.3072029-1-surenb@google.com> In-Reply-To: From: Shakeel Butt Date: Wed, 30 Jun 2021 12:00:38 -0700 Message-ID: Subject: Re: [PATCH 1/1] mm: introduce process_reap system call To: Suren Baghdasaryan Cc: Andrew Morton , Michal Hocko , Michal Hocko , David Rientjes , Matthew Wilcox , Johannes Weiner , Roman Gushchin , Rik van Riel , Minchan Kim , Christian Brauner , Christoph Hellwig , Oleg Nesterov , David Hildenbrand , Jann Horn , Tim Murray , Linux API , Linux MM , LKML , kernel-team Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=ZKBY6Vft; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf26.hostedemail.com: domain of shakeelb@google.com designates 209.85.167.42 as permitted sender) smtp.mailfrom=shakeelb@google.com X-Rspamd-Server: rspam02 X-Stat-Signature: y1nr57mh6otoih7anp6nk76oeihhxise X-Rspamd-Queue-Id: 5815D2001709 X-HE-Tag: 1625079652-818425 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 Wed, Jun 30, 2021 at 11:44 AM Suren Baghdasaryan wrote: > [...] > > > + /* > > > + * If the task is dying and in the process of releasing its memory > > > + * then get its mm. > > > + */ > > > + task_lock(task); > > > + if (task_will_free_mem(task) && (task->flags & PF_KTHREAD) == 0) { > > > > task_will_free_mem() is fine here but I think in parallel we should > > optimize this function. At the moment it is traversing all the > > processes on the machine. It is very normal to have tens of thousands > > of processes on big machines, so it would be really costly when > > reaping a bunch of processes. > > Hmm. But I think we still need to make sure that the mm is not shared > with another non-dying process. IIUC that's the point of that > traversal. Am I mistaken? You are right. I am talking about efficiently finding all processes which are sharing mm (maybe linked into another list) instead of traversing all the processes on the system.