Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp569726pxv; Wed, 30 Jun 2021 12:08:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyn7/iiN4XEKiI2MsYPuC5NhL5DOB83LsZBRmqbXUqd9QuerOpbxzZ272dp5mR/qvkyxSdM X-Received: by 2002:a05:6402:27c7:: with SMTP id c7mr28896578ede.272.1625080122649; Wed, 30 Jun 2021 12:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625080122; cv=none; d=google.com; s=arc-20160816; b=JtRMu99fn+xfGg25K0A6DzUhSK7bwtx9ucZaANcg/y+xW6VqDDwa+LqoStdbU7Eh/Z Dsw83GPzZms4K1Rgs23JS1DBVsr7ngbBnC6cIYF2fAuhUYvEVGxbmzx8QrcQBGUpgQc8 TdNGxDMIC/EMV25VXFLt5lqzMsNx0SuG/yXZn2UuKZ5uOUZhmFiH94WZ2EyDdPRJXuiD JsHy32vCtaginVYV2QiMLKHJjooz6FY32qdxZt+KTWOZsaIRckFq+a8q535udoT2jvaN o04s11tfX5eEWvI6NTXi08mW5s53F0jAlZnxdIV+AZs4ShaZqmUcLX7VT9ZZx/aiJksF HUmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DBXYzxuYbrUfubIQ6UvGkUSdg+WS39I5c22pRkza8yU=; b=QJuYR5HBm46OYZVYaRJ2nH+tzYeJMn+ic6kAl+3uwF59lc/2phHqDrqX+domb+vfZQ rueb9i7Ia5gsUojj+OqZgxUdpostG30SxpJpuAYFxj3MI8WQRTYrQVztYjdzAU9GjW1u My4Z7LCQYtrFGmCU+TCR/4YxDKOdPC7zYgDDse1rkHzf04slTLYFes/RrlzkCDSAwyZG je4GDU8Ajm+k4kDMWM4DCGYV8FF5w5Y+GEPoMf3xAQmHYbZJwigMHCRnBdOQvY/g6pUx bp8UFGMKMP+nzA7R7O7TTB2eBCFipEnXYOzkMLVXJCsDAYLLhF3oBMt1BX3hJWfOc5vW whNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=T2Nrl9yc; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ne4si3083528ejc.510.2021.06.30.12.08.14; Wed, 30 Jun 2021 12:08:42 -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=@google.com header.s=20161025 header.b=T2Nrl9yc; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233152AbhF3TJV (ORCPT + 99 others); Wed, 30 Jun 2021 15:09:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233085AbhF3TJU (ORCPT ); Wed, 30 Jun 2021 15:09:20 -0400 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC8DC0617A8 for ; Wed, 30 Jun 2021 12:06:51 -0700 (PDT) Received: by mail-yb1-xb2b.google.com with SMTP id i18so6668603yba.13 for ; Wed, 30 Jun 2021 12:06:51 -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=LcMOrdNaCQ+lKwvxr6cdQnz9v2e61JZuZaVP8Ywg2k44hdqBSRjLkR5d6H+3G4BNTv KEN72pjb26l6TGzCh9q5vrsxd64OdvGjoqRxD2ehhED37AF6vhklEI/hNCUuN7ewmYVT 8SdtANxQ1kIpBBKH4zsb/wq1DRsjTO/aUoAWotlMBG0wr6fRQCxte5qyFwGElnTWoYIn FN0k2EZvnksBxInplMZXV7Y5t0XtWGuM7PckcJf93uCmwYU62ENnP4q3cJlwt4V7vDy5 TcKzrpAcTWIQCM0OScYzWovDnLMxLKhD7Vn1iHRYLlj36R4cpKZg58U+DXkBe2B0M0k0 8rEA== X-Gm-Message-State: AOAM531NGWOtCwlVCZdtd5gv+RYmEAKhY3pc0ehcSejeKvrWbSiU2olL iStpOTGtwac7X+M2uDfermyi2HdLNQPRqZTqBXtHkg== 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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!