Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp542343pxt; Fri, 6 Aug 2021 08:02:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCsH4WTUw+8zsN2Xv6WTZx+zDPC7E4R4kNvkOesgslpiWVWyKvJk8yYc9ybgG53FB81jNp X-Received: by 2002:a05:6602:14f:: with SMTP id v15mr967438iot.206.1628262173919; Fri, 06 Aug 2021 08:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628262173; cv=none; d=google.com; s=arc-20160816; b=U/1Agu0FEDLpjoj84J6ZzErsx825n3gs/naFWKnvnS2SroOHoQWR9aP/8Difb4j06x VPwlTUWrPPkRU45fQTOJS6jrLYsp+0b2fNVM5UGSPZhLQB7b6BINQG6pPmqT757jJ/dL 88d2gZgUUYzwbq1HqoF6e+sM0WA3noVLeUb/xcoDSegUYS//WEmN/VSqU2jqDdWY02bn +r0N4viqPtdEKY23nxCYaywf3Mo/cJ4DX6oxZ+dyLgxM+zQ8dVFZmVh9J2/e8Vua++4+ xB3XnJ25htztpdXGjY3ceIVU84hzqxq841yIa62+wdPM7lcbXcNt7WRN0KexV9Clw9lG bNCg== 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=Pz/ZNLrZ0O+ZYLO34S4orrCykgTqtG1p1sxk4AuVhP8=; b=kUADYmxQt/K8MVbsMnAwDkBHZgPwnH38gUR+4IrhY1QivAtUN83RenqvJMi0CSs/bI KUcJLJEySdRi0oHyKYxlM0quLVbX8ASqfXwU1wdSib1AVcjT5hWBR7g532vsHs4BrDO5 Tap44Rf7xVIjtlrmxzbcDTRrgNuhvAe3qsm8GzQxqgAN5xW4g4Su1FPyY8uEUFFaP3qK u3k+8CHRNy73V1HpaHgpIIHNCq3UV80gGbIlYpQ/X8pSU5PraafDvUhmxvKimNSrrDOa j793AlD9f36UhSe0XEDMunxjv6WbaaHpzsYVwKmKSmgkcBFZ/oHisKJgt0bCKM87DCjm diyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="cGHj/WVq"; 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 z4si9209876ilo.41.2021.08.06.08.02.41; Fri, 06 Aug 2021 08:02:53 -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="cGHj/WVq"; 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 S244512AbhHFJXq (ORCPT + 99 others); Fri, 6 Aug 2021 05:23:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244500AbhHFJXq (ORCPT ); Fri, 6 Aug 2021 05:23:46 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67E03C061798 for ; Fri, 6 Aug 2021 02:23:30 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id b6so333895lff.10 for ; Fri, 06 Aug 2021 02:23:30 -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=Pz/ZNLrZ0O+ZYLO34S4orrCykgTqtG1p1sxk4AuVhP8=; b=cGHj/WVq/vdRsPecp7h5K9JfcZgFhYagyOxvNOodNjPWx1ajkrEXS3JlyTiNibU3Zp SwCEr2nxYnnoN/rDaQwb38GFSgdZl2Kq0S1ZixHKqp+2avGFzfRNz6/iVMXsnP13GDXH RgM2ccrAp/Y1PFbzphGj/HwyUf/rf0UTzlmJOICfUXjvGmeePTEJrpD9OV4lH2mafCPY EUwoVZfgNlJ5UV5dhZ/CcQ8uSISli8alXXvbGedEUPmFhOF7U0zEPU4QCO18qhf9yaxy TcA08g0vlBeSatSxXBIZQVQuFf1Og0jFqjL2CJHgmHoOtEAS/Q+fp37wUoAuWgX6aBA1 VJjQ== 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=Pz/ZNLrZ0O+ZYLO34S4orrCykgTqtG1p1sxk4AuVhP8=; b=arTjRP92trpmG+VHt0ABfsziko5n1/X8leW904+QRGYD3de7a+BlqVdiYN18p+iZ2b yCMzp3Zt8OtrxFF1eCSOWgyIN54dqEnwKP+MOOVYu9/rGtPI+h9L0Fa+Do2MP1fQ0Xe9 bNonbazdxo2DghOsAqAAhxnX1QWbPk+iyUkKIv/0sM6dASqHgKKB5DBQ4G52gNLQxh2j IrnDxa5wTRJxm/ZD1IS+0TvUXApLFWNsAEzecse0izS+FJMi8f1aXL+Qq4gqLxmFGJ7X oKpYIlxuqktkwa3V8VFl6Wz+HcPK699L6TvJg8sPdgvi/A5yCTe1BgRg04kM/Fun/Y7f j3zQ== X-Gm-Message-State: AOAM530w/cvrtEncb9sDlgNby4EOJa7R0RfNn0eZOXoZ7y+QiVrowdaV /l8gGJYWCUwd4E5fidEzdssbQAQEAY191RQOlP8FFw== X-Received: by 2002:ac2:57cd:: with SMTP id k13mr7112194lfo.117.1628241808578; Fri, 06 Aug 2021 02:23:28 -0700 (PDT) MIME-Version: 1.0 References: <20210805170859.2389276-1-surenb@google.com> In-Reply-To: From: Shakeel Butt Date: Fri, 6 Aug 2021 02:23:17 -0700 Message-ID: Subject: Re: [PATCH v7 1/2] mm: introduce process_mrelease system call To: Michal Hocko Cc: Suren Baghdasaryan , Andrew Morton , David Rientjes , Matthew Wilcox , Johannes Weiner , Roman Gushchin , Rik van Riel , Minchan Kim , Christian Brauner , Christoph Hellwig , Oleg Nesterov , David Hildenbrand , Jann Horn , Andy Lutomirski , Christian Brauner , Florian Weimer , Jan Engelhardt , 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 Thu, Aug 5, 2021 at 11:40 PM Michal Hocko wrote: > [...] > I think you really want something like this: > > if (flags) > return -EINVAL; > > pid = pidfd_get_pid(fd, &f_flags); > if (IS_ERR(pid)) > return PTR_ERR(pid); > task = get_pid_task(pid, PIDTYPE_PID); > if (!task) { > ret = -ESRCH; > goto put_pid; > } > > /* > * Make sure to chose a thread which still has a reference to mm > * during the group exit > */ > p = find_lock_task_mm(task); > if (!p) { > ret = -ESRCH; > goto put_task; > } > > mm = task->mm; mm = p->mm; > mmgrab(mm); > reap = true; > /* If the work has been done already, just exit with success */ > if (test_bit(MMF_OOM_SKIP, &mm->flags)) { > reap = false; > } else if (!task_will_free_mem(p)) { > reap = false; > ret = -EINVAL; > } > task_unlock(p); > > if (!reap) > goto dropmm;; > > /* Do the work*/ > > > dropmm: > mmdrop(mm); > put_task: > put_task(task); > put_pid: > put_pid(pid); > > return ret; > > -- > Michal Hocko > SUSE Labs