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=-11.4 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,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 7FDD6C433E7 for ; Thu, 15 Oct 2020 19:32:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BE314206E5 for ; Thu, 15 Oct 2020 19:32:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="c3ipEjBI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE314206E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B571B6B0062; Thu, 15 Oct 2020 15:32:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE05C6B0068; Thu, 15 Oct 2020 15:32:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A90E6B006E; Thu, 15 Oct 2020 15:32:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id 5ED4C6B0062 for ; Thu, 15 Oct 2020 15:32:36 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3A9AB362B for ; Thu, 15 Oct 2020 19:32:35 +0000 (UTC) X-FDA: 77375156670.17.hill28_5f018c127217 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 17E4F180D0180 for ; Thu, 15 Oct 2020 19:32:35 +0000 (UTC) X-HE-Tag: hill28_5f018c127217 X-Filterd-Recvd-Size: 6106 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Thu, 15 Oct 2020 19:32:34 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id b127so188754wmb.3 for ; Thu, 15 Oct 2020 12:32:34 -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=t4HayBldfHnr9vzT+RQI1NZht7qEgetcfgLsh2qzQDc=; b=c3ipEjBIGCQrkIDwRMsWKNjMrVyvyC8372nQq5KeA2TZ6YUB3EdnHp5+D6+1BYCsFl zslNV27aKU0qEl6JWzc4IvaiRMoVOzL2xP58HqntHSxeJkcBzn+7eUyS0BsO3G5hYWdm htlxDaxUXjrY7OTOtPwK93gRPUk154t2iSD5yV7dc53BDOvfO955ueahKQdHan2dEwNM f8imtv8OTkaFuvm75kDp5eMpddgZSVc5sbTQJkpvM1wSrsJ0SQeJ5iILhKnH2PmMvBIi xRO7tSjmhO/O0I3EkHFjxWVEanPvd0JTl6rmo6n5D7z+SPTiJ9HdxaXhuBJD+mDBfwLw YTKw== 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=t4HayBldfHnr9vzT+RQI1NZht7qEgetcfgLsh2qzQDc=; b=sxPSgsRoasGAJdPEc4GQW1OhfpI1xZG/Tw8TAJkZL8PjuvAMT9dVyBcOdVtY6MxCdj D3RRox4cOgFcaxpVkXZAWI86Nfo+Oi24bklPCPLIFdgSwYmYQu41+fhZ27UA0EY2jzjg aAawtPc5poOszNamEn4aZGW/cGo/uisZGai965rKBlDHXAfLCYCU2JRco/qORD9KhxuA hbWM8qzJJGvMq5JLR4jTP3dGOFOxHFpVb7eB0J1rn2lQCHsYvu6cuydumZfiAzIltzMg 2kP0ixGEZ7CZHJhlSAe8IbSwp6dfYeL5u60bHadkm/kWIcnjy7eVElB/zuHgLP0vHfYF fAmg== X-Gm-Message-State: AOAM530T3Jo2+4Iodyv7tUYvPZ9otDag3j9sLng1+59+KE9IU+u4w1c7 t2h5GhsBmJh1wO57gUwPBJARiubKlUeFUTh+o7lRkQ== X-Google-Smtp-Source: ABdhPJxXYX/Zl8p2deWeKmdwebpm8ejyMBd5EqRJXZoD2uNDwfMK5sT461+XZWIZ1ox7sntItqlyH+Vzw7IjUtinNN0= X-Received: by 2002:a1c:111:: with SMTP id 17mr213767wmb.126.1602790352867; Thu, 15 Oct 2020 12:32:32 -0700 (PDT) MIME-Version: 1.0 References: <20201014120937.GC4440@dhcp22.suse.cz> <20201015092030.GB22589@dhcp22.suse.cz> <20201015184349.GA3930989@google.com> In-Reply-To: <20201015184349.GA3930989@google.com> From: Suren Baghdasaryan Date: Thu, 15 Oct 2020 12:32:22 -0700 Message-ID: Subject: Re: [RFC]: userspace memory reaping To: Minchan Kim Cc: Michal Hocko , linux-api@vger.kernel.org, linux-mm , Andrew Morton , David Rientjes , Matthew Wilcox , Johannes Weiner , Roman Gushchin , Rik van Riel , Christian Brauner , Oleg Nesterov , Tim Murray , kernel-team , LKML , Mel Gorman Content-Type: text/plain; charset="UTF-8" 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 Thu, Oct 15, 2020 at 11:43 AM Minchan Kim wrote: > > On Thu, Oct 15, 2020 at 11:20:30AM +0200, Michal Hocko wrote: > > > > > I do have a vague recollection that we have discussed a kill(2) based > > > > approach as well in the past. Essentially SIG_KILL_SYNC which would > > > > not only send the signal but it would start a teardown of resources > > > > owned by the task - at least those we can remove safely. The interface > > > > would be much more simple and less tricky to use. You just make your > > > > userspace oom killer or potentially other users call SIG_KILL_SYNC which > > > > will be more expensive but you would at least know that as many > > > > resources have been freed as the kernel can afford at the moment. > > > > > > Correct, my early RFC here > > > https://patchwork.kernel.org/project/linux-mm/patch/20190411014353.113252-3-surenb@google.com > > > was using a new flag for pidfd_send_signal() to request mm reaping by > > > oom-reaper kthread. IIUC you propose to have a new SIG_KILL_SYNC > > > signal instead of a new pidfd_send_signal() flag and otherwise a very > > > similar solution. Is my understanding correct? > > > > Well, I think you shouldn't focus too much on the oom-reaper aspect > > of it. Sure it can be used for that but I believe that a new signal > > should provide a sync behavior. People more familiar with the process > > management would be better off defining what is possible for a new sync > > signal. Ideally not only pro-active process destruction but also sync > > waiting until the target process is released so that you know that once > > kill syscall returns the process is gone. > > If we approach with signal, I am not sure we need to create new signal > rather than pidfd and fsync(2) semantic. > > Furthermore, process_madvise makes the work in the caller context but > signal might work somewhere else context depending on implemenation( > oom reaper or CPU resumed the task). I am not sure it it fulfils Suren's > requirement. > > One more thing to think over: Even though we spent some overhead to > read /proc/pid/maps, we could make zapping in parallel in userspace > with multi thread approach. I am not sure what's the win since Suren > also care about zapping performance. Sorry Minchan, I did not see your reply while replying to Michal... Even if we do the reading/reaping in parallel, we still have to issue 10s of read() syscalls to consume the entire /proc/pid/maps file. Plus I'm not sure how much mmap_sem contention such parallel operation (reaping taking write lock and maps reading taking read lock) would generate. If we go this route I think a syscall to read a vector of VMAs would be way more performant and userspace usage would be much simpler.