Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1477230pxv; Fri, 23 Jul 2021 09:11:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlGX+qLG9wpZmUbSzVQDnyzoVpdqxuQSaHxkGJ0oUwzP8Nq5AMfJ1eyyOroYw6/vLLlOx3 X-Received: by 2002:a05:6402:111a:: with SMTP id u26mr6334035edv.260.1627056714748; Fri, 23 Jul 2021 09:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627056714; cv=none; d=google.com; s=arc-20160816; b=HxOmTeQSIDXLFyUNkHb/d4VwheiOXPyZxwFs/Gjidqpl0Mw2Xl17rp0gpTziogS56t c9cgO+AVLPpEOH9KN9YW0qLlDd61vcvC+vNAZFnjJWpMebqUamdU8TTE5DuBy9hTng+s 9Tqo5aXVG6X455UtSeOBxux0UfNwh+3vjcsSh4bEDlyDVcYiqEVmjBYm921MGcRN6dMA E2BXo7PAUyunIFssPh66i7HxFkHlY7ImJ8C3S5ukJMBLt1qF/I37XX03+CguvSy76GVh kTfY4vS1btU3JdFc63U90tIVX7kCATxnFQFV5D+4ZO6G6HQbXcziV2qa3Y/J/hS3BzLw zRZg== 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=9VI9kjwn56WWv5KeEalz1sUOG8bqHQgJMneVLRITpE8=; b=VJ1FZTo3jUPFFUUsol7nJpZryCOeJvzwFRJUqJmqsXjmbNJbstYlGfU9HSL6rYm5i1 NO7HDQ96/SV+RxY123Ga29Q97LOIgEuZ/jMt9pi8UpyJfGijqjk6B0mJ2p73HZXIhCzd Iwpqw/3tIPMvDq1yXopjQ7ygC7c+MrQxlUucF5qT+m+zHX/MlA6lnqeR4H13iRQ8S41s 6qxx7viAeLGEFvP9T9X7L4yebeiLItJyaUACwJ8iV+Cto8Na7jKyxgTvesb6PXXRcQIc +hlkONn2GV6fM7AXQgOkscgFTlsxoo248Pk6nux/3xeU6Qhr4SZozKtbDngvDwidkQwf OnVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="HnSX6z/1"; 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 hs24si4436211ejc.287.2021.07.23.09.11.29; Fri, 23 Jul 2021 09:11:54 -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="HnSX6z/1"; 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 S229788AbhGWP2b (ORCPT + 99 others); Fri, 23 Jul 2021 11:28:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229686AbhGWP23 (ORCPT ); Fri, 23 Jul 2021 11:28:29 -0400 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12FD0C061575 for ; Fri, 23 Jul 2021 09:09:03 -0700 (PDT) Received: by mail-yb1-xb31.google.com with SMTP id l145so3087581ybf.7 for ; Fri, 23 Jul 2021 09:09:03 -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=OWWWUwIa7A0p50JyAf+KaeKDX98QWTecRXJkc9KT6Tv6i45AOOr/a7QlClxIVWVuvN FTsU/kOLkEGN+RC2qT9UpAGo/LQ0CoEK+E4780G4T3P+/Zng8O7J6HY1Y/5+z1ZfcSai pdegvkdCvs2ufv+HKyjGxdP3igC7ixF9KJtkPSve2ppi0m5xIU3V8ufjc7SE65HcQnzq q3zN3Aebc86qXy6bN6PhPrJj5/+cHRtp8wfnsQ4UqbU7Fppvcc2UgLQwP/VzgZ8lyYd/ KTihpBaLmdBRgSMcIXhcDIaZ6rLtHWOSuMqtO99TMYKe8uF5G7XMxy80TtPOyWCAYC6e IAXg== X-Gm-Message-State: AOAM532LU76tV0HOO5th6OBPFyBQe27+xp1of67Wfz+OHlb4n6FKk0GQ 60VlGuu5Duw7NlO3MF8H+tRQLolltmNuvapZ720nhw== 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?