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.3 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,URIBL_BLOCKED,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 2781BC4338F for ; Fri, 23 Jul 2021 16:09:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AD99E60ED7 for ; Fri, 23 Jul 2021 16:09:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AD99E60ED7 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A604F6B0033; Fri, 23 Jul 2021 12:09:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A108F6B005D; Fri, 23 Jul 2021 12:09:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FEC56B006C; Fri, 23 Jul 2021 12:09:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0140.hostedemail.com [216.40.44.140]) by kanga.kvack.org (Postfix) with ESMTP id 75DE26B0033 for ; Fri, 23 Jul 2021 12:09:03 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 28CEF17A83 for ; Fri, 23 Jul 2021 16:09:03 +0000 (UTC) X-FDA: 78394336566.18.9556B3E Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) by imf16.hostedemail.com (Postfix) with ESMTP id E5EEFF00374A for ; Fri, 23 Jul 2021 16:09:02 +0000 (UTC) Received: by mail-yb1-f173.google.com with SMTP id l145so3087580ybf.7 for ; Fri, 23 Jul 2021 09:09:02 -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=9VI9kjwn56WWv5KeEalz1sUOG8bqHQgJMneVLRITpE8=; b=HnSX6z/1YI5rXl+MYn2P5T5hZOevSHHeW+jNbG8MGohEZ1Wuzi7t/jwv7XCJH6AZ1I FD7INh7OuYKWpoYPUR/p11IO2kSJrFj2OYH76szUajxedJqjkOqACB3OK0tmGwbMHKJz fc8yyxJCdPtwHy+ViMLE/PlORPVrJlXYvpXUC3rSvO/NW4TBGljDlWullE05QB+tILjC ZgrUB62VLO4dUlmpKWCFz5aIQkr/5tBgZk57sMzG/vtDDafyDTkd0h9cQRMRjo+bdKha oabft7VQE1z/eUZMwE3MAcvEQDBLVoIqdYF+/WJJgqDLHCAOXeYAohYVKZLIZWMvc6th VsTQ== 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=9VI9kjwn56WWv5KeEalz1sUOG8bqHQgJMneVLRITpE8=; b=mQkYgHfnTPT0kNntJa2SOPIQaWVxUlne77vT3u3ge/8eGe6643Llzaiv1bzxlHxj38 GmvpdYLKG6Vb4svMFncSw6sWem3n9n//5ijTJRr/po4wK+l2i5RV2RbpDecX92doYLNR y/hEQLTQdcpxnCknotSh59FB2wHyT5CefiOOWR4ygJ6Bkw3Z1+w0ntmVo+XVJ+QtZzUn EdxvDeU9Ofl5A+QxosMx1qqlwg9ZHLj3QsvccSrPUS3vkrCeuuS8XQIn5dzdxdPuQzM/ 4PSw3sfu17M6xoI7ffeLO1TgOU7FkR4cwUw2CWxcYGtcUwJt4CCGr5BCXRoXAtYzOTXd WyPw== X-Gm-Message-State: AOAM532ELo/+dNeijDEXXIpYacZsedflOlzJ+Nq58K0XjghjzYtdYD4p G9L1xIF+n8d9+gF4kXJNGq5pHyrv2ycqrXrm5NRfew== X-Google-Smtp-Source: ABdhPJxn9uo3Wjfj7r9vGXqp6Gdk3SsItVIldrE0qi/gRxSuu+MaBGMIKTB9xh6E3rjPRojpVOS308evtSnl0wGLsS4= X-Received: by 2002:a25:5f11:: with SMTP id t17mr1954300ybb.84.1627056541923; Fri, 23 Jul 2021 09:09:01 -0700 (PDT) MIME-Version: 1.0 References: <20210723011436.60960-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 23 Jul 2021 09:08:50 -0700 Message-ID: Subject: Re: [PATCH v3 1/2] mm: introduce process_mrelease system call To: Shakeel Butt Cc: Michal Hocko , 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" X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E5EEFF00374A Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b="HnSX6z/1"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of surenb@google.com designates 209.85.219.173 as permitted sender) smtp.mailfrom=surenb@google.com X-Stat-Signature: zmybr84yn59bf5w9w6s6o7heotfysa69 X-HE-Tag: 1627056542-427025 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 Fri, Jul 23, 2021 at 6:46 AM Shakeel Butt wrote: > > On Fri, Jul 23, 2021 at 1:53 AM Michal Hocko wrote: > > > [...] > > > However > > > retrying means issuing another syscall, so additional overhead... > > > I guess such "best effort" approach would be unusual for a syscall, so > > > maybe we can keep it as it is now and if such "do not block" mode is needed > > > we can use flags to implement it later? > > > > Yeah, an explicit opt-in via flags would be an option if that turns out > > to be really necessary. > > > > I am fine with keeping it as it is but we do need the non-blocking > option (via flags) to enable userspace to act more aggressively. I think you want to check memory conditions shortly after issuing kill/reap requests irrespective of mmap_sem contention. The reason is that even when memory release is not blocked, allocations from other processes might consume memory faster than we release it. For example, in Android we issue kill and start waiting on pidfd for its death notification. As soon as the process is dead we reassess the situation and possibly kill again. If the process is not dead within a configurable timeout we check conditions again and might issue more kill requests (IOW our wait for the process to die has a timeout). If process_mrelease() is blocked on mmap_sem, we might timeout like this. I imagine that a non-blocking option for process_mrelease() would not really change this logic. Adding such an option is trivial but I would like to make sure it's indeed useful. Maybe after the syscall is in place you can experiment with it and see if such an option would really change the way you use it?