Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp565725pxv; Wed, 30 Jun 2021 12:03:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPXdfBuJwak0SCOroeIznIMMdwqy/tRCPwmtY4N+zMhnEER4ibvkh3nl1OVMejuIVhiXRY X-Received: by 2002:aa7:c04e:: with SMTP id k14mr47356696edo.157.1625079800974; Wed, 30 Jun 2021 12:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625079800; cv=none; d=google.com; s=arc-20160816; b=nB4aa7HzhCWM8pSXWnYT6nhucpLQD57TDLt0gl0WtmN5ggWgwGsg7+aDYJ8LujHb+d wBleFt2JECUGyNN01ZeqWVKx6LfOUmZrr2WQ/JW7Ld7LpO7FWzdTpDFVupPT+vVbqZyH j5wuEFIe/hzs6YMdpVaGz7GwW2ARpP/jA3tq+m0mlC24m2NIi4FCQ9KOc6dHPRVlERiB LNIGFqw90Yqt4KhgT8cw4eaDE/o1Wko0FfiQLaW1reORH+4Rti77NEJPR9tCfjivxRIA hBSxzGDKxn5n4qP96Go/ufPgPcWhLChTykk5pZxdtNCfDGNj9uE9cnVszr31HTJlwFOV mCaA== 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=AEgh9Jy+v2hf9QQxXrhqFRUWrnkAgTuVo3us79cOIOw=; b=LHd8BcJnnYzSAEg7z9On/HEVgeEUi03okZLrD/4vCVzW6Eq5y8pQe9k10OQ3X3U4IY 1teDDwn9w843KuTCszbsF2yZX9r7yD08LGDp3B2WQfZSaMTRISd4HxH2IofzAJIs/X9I Lbtt8+sKB8omcYUCqS4cYmSJKa030ZkvxfjV0/2cJ+Qd5BSBMqgVnwWWP2xtEELADhhn sPFzARXVQ73COc+J6/P3W7psggUvaaJN7qBVlaccxXCdciODe9iJ++ymijhC6/82kpEa G1VIaprNJ2owo0Y1jjL+XXKhJ5eK19M+ov5+3jSK3vLQ1ZmOAqcq4pfEgxyA8pbnTAh5 1UeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZKBY6Vft; 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 bo20si7693112edb.17.2021.06.30.12.02.55; Wed, 30 Jun 2021 12:03:20 -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=ZKBY6Vft; 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 S233462AbhF3TDW (ORCPT + 99 others); Wed, 30 Jun 2021 15:03:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233085AbhF3TDV (ORCPT ); Wed, 30 Jun 2021 15:03:21 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C826C061756 for ; Wed, 30 Jun 2021 12:00:52 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id d16so7035809lfn.3 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=ZqjnYn1HN3IMFldvXWZN8iCJXdiI3QSfMQo1CvL/i4Siy8zaJPRTD/kY9kcWZFZJuw wi8WdnC4jy1J9WOMbkJKhWpq0j9d7LULOwcpf9AQVYOmvaNefOKzs9DLTSSo1yFQIAXt SsJlw94zfVCwwh6etGf1czuSJ+9B3yp808T34vGQTShQBbyAEBILxPzuzMUqf321V8dR NSF53Xmxdpe6R7vGdDm5sxfvg+QNhQwqgtRgF4ytqQiZ59mkSFsDicN4dCuTjY2+5OVH 3ZZzyziwCd/auBLUG2w84gV3CDctrAnRC/WdSe+auZqk9jin3Uad9aYxzjnTFxKRrIMg PM3g== X-Gm-Message-State: AOAM532jzbRy79nNj4MWt8AM89xlrOMK7OE6omUdg987gJMtRzig/1F6 UCczWMR87PDMd5Zbpy8mZAtjFvGfUu57kadBf8Vd+Q== 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.