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 E2322C11F68 for ; Wed, 30 Jun 2021 19:06:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8D93661476 for ; Wed, 30 Jun 2021 19:06:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D93661476 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 C21128D01C2; Wed, 30 Jun 2021 15:06:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BD10A8D01A2; Wed, 30 Jun 2021 15:06:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A714B8D01C2; Wed, 30 Jun 2021 15:06:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id 803C18D01A2 for ; Wed, 30 Jun 2021 15:06:51 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 4C7CB2203D for ; Wed, 30 Jun 2021 19:06:51 +0000 (UTC) X-FDA: 78311322222.03.67CCDC8 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) by imf21.hostedemail.com (Postfix) with ESMTP id 03FF5D00014E for ; Wed, 30 Jun 2021 19:06:50 +0000 (UTC) Received: by mail-yb1-f181.google.com with SMTP id g5so6698638ybu.10 for ; Wed, 30 Jun 2021 12:06:50 -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=DBXYzxuYbrUfubIQ6UvGkUSdg+WS39I5c22pRkza8yU=; b=T2Nrl9yc5bjJCN2r4qbI6DLyowI5EaeRUrMata/pmX303u6wAyJIcw4NJy6H2IG0jx ayfcoRDTEG8x5PfQm04GcJhdXQHmohsFJTcUv1ye1wBNsknk8ank0NgypWy1vnbB7ZHZ FDgGaFmvQFbTPZCQ36V/HyXzi9EGwi5c4D+LJ9C93+bnZZB31GaQj8jG/y1f6Ku/P/by ZPO0N8K1ZMHgRzaMHFE13qhg6v2Ia+Bf28IlNYSvUVczDNqNHecB2AEpG3CUcdV4slwt AsYWsHTL4OLFBRXMIyUcizgchgRt9zZykuOmi6il6g+O5PKN49ikvHvYHbBiMQqETs/z nyAA== 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=DBXYzxuYbrUfubIQ6UvGkUSdg+WS39I5c22pRkza8yU=; b=jzqjTikusxkZg7aCMuimhePKv/tcRr3bdUFZ/sIyGRdly+Tl7uZHTpDj/cov0+RT4F 0oK08z4NmqjIisKbpfuj75jG0b2NuiJVvqk470iGh2P0C20i3TBEACQ76dKQfBw+MMXH RmO4DO8qpckr+73mLiy1dsxJFhIg4Plp+qwitY3/4iabRL2ZH8Li/lg5IgyQ1mhqoBoU SpJ8i+sdFGUg3hHYVvA0M4bA7l9cyADiwi9nM0KDEMb7VERGwb7+4YZXFCwO0AkOrWYN 66+EgcNtIO4Q4vCu/9v8ZVgR//U+vqNuEv2U1NIFR1czShBZvllh/8jiwUKWbRIS3/Wj psJQ== X-Gm-Message-State: AOAM5333NRWdAETfoqGsJ3ubJoemQ6uXScYGD50vp/+8KZnkWq9m7w8j qPLljjfixSWULVqnrKHOzuru6CvH+W1mFrWzlQ+COg== X-Google-Smtp-Source: ABdhPJw7XehJAJ/lTBUWul5miVd/lSGPIC8Gj7POEguNh9f02XyBFfJ2p2aSbCed9UbXE8en6B/RWG9jpWX4AJT5NwQ= X-Received: by 2002:a25:9945:: with SMTP id n5mr39428387ybo.294.1625080010148; Wed, 30 Jun 2021 12:06:50 -0700 (PDT) MIME-Version: 1.0 References: <20210623192822.3072029-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Wed, 30 Jun 2021 12:06:39 -0700 Message-ID: Subject: Re: [PATCH 1/1] mm: introduce process_reap system call To: Shakeel Butt 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" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 03FF5D00014E X-Stat-Signature: 9aoamkzujrw1bouq6z5zodxezefnbhjq Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=T2Nrl9yc; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf21.hostedemail.com: domain of surenb@google.com designates 209.85.219.181 as permitted sender) smtp.mailfrom=surenb@google.com X-HE-Tag: 1625080010-181317 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 12:00 PM Shakeel Butt wrote: > > 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. Oh, I see. I think that's a good idea but belongs to a separate patch as an optimization for task_will_free_mem(). Thanks for reviewing and for good suggestions!