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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A95A2C43334 for ; Thu, 2 Jun 2022 15:03:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 184B86B0071; Thu, 2 Jun 2022 11:03:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10E9A6B0073; Thu, 2 Jun 2022 11:03:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EEB5E6B0074; Thu, 2 Jun 2022 11:03:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E11606B0071 for ; Thu, 2 Jun 2022 11:03:05 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B0E0033C9F for ; Thu, 2 Jun 2022 15:03:05 +0000 (UTC) X-FDA: 79533613530.21.3BA2043 Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) by imf20.hostedemail.com (Postfix) with ESMTP id DCD591C0064 for ; Thu, 2 Jun 2022 15:02:45 +0000 (UTC) Received: by mail-yb1-f177.google.com with SMTP id l204so8760715ybf.10 for ; Thu, 02 Jun 2022 08:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VrpT+1Lsi6jca7SxhpmDUEdjKT7O5trvRYqg6tF6OAU=; b=bMFgFjuZwiNL3X7wdkEkTZzHCUQm9i5bLn6Ex5kneLO2hUl4jOJQTYYjA+UutVaAID anUZF4jOLMaIGArGNX7y1nBf3KiSy0BoWQfnYS2smhON95cGRc/KiLZ3abUysz/NECfr QThUVZC4mwvj/1YMiVQVTS174pcrAgpYJvpaXAI7mI4t+orRJkwY36K819fBIpJoUvQM d5ukoDbpt0eQL9AfJMo4CwS9jmMbWGkphsXf672XfKgmFWEq2eaUnIS5SQR6+4II/Snn 8oin9q+XSMa1+8WxFOK2/txLuyDzemw7aTER9kKtqhL8R2drfXTGvJynpjU3BAm5srCR 7Xhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VrpT+1Lsi6jca7SxhpmDUEdjKT7O5trvRYqg6tF6OAU=; b=gHbnremG11sd60hWNIIrBnPmSOSc4bBduMO5vuFtAcKpgxlJf3swrMgJudQ0+10yEz PglpAvi68jtQIXEh02NCsg6sy016841i0u/RBHV06Bvddlfc471Tu9NE4LtsXqd02Ula 5JRw0nnAy4vRmvEmfdt/BkCfTunTOd2ZFiKhgOSyddrBb3VdGtnsHMSqob5ww6P486E/ r48sIH694C+3WQB2fiFuH8Sqe4NbVRpf28EHcHwJ6Aa2KdPcyPZNH3dUhAMWT1zfxcz1 1i28wbljoEVSg4T+1kKF+52x/oykONuOCW0uKQK+yA/NOWlA+EmtG1hZ3eRFYlZQ9NoM iFXw== X-Gm-Message-State: AOAM53142VWQXuXtu+72aeup+/ZKQI68/RT4lCC00h7wqHLVoqIkVzP7 DwSwCeM17h+K4nDwU4twynENK7e+vSY++xm8UtL+6Q== X-Google-Smtp-Source: ABdhPJwN5nVrGFtyA2hSIkpqsP/GYytTm6u1LFXXIJlIvve3dP28aJBB1N7bZsSiCcqwiuDKTw3A65nKpXG5EtlHRjc= X-Received: by 2002:a25:2ad8:0:b0:65d:22a5:f19e with SMTP id q207-20020a252ad8000000b0065d22a5f19emr5587363ybq.426.1654182183552; Thu, 02 Jun 2022 08:03:03 -0700 (PDT) MIME-Version: 1.0 References: <20220531223100.510392-1-surenb@google.com> <20220601143638.9e78c470d2c980053cc8059a@linux-foundation.org> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 2 Jun 2022 08:02:52 -0700 Message-ID: Subject: Re: [PATCH RESEND v2 1/2] mm: drop oom code from exit_mmap To: Matthew Wilcox Cc: Andrew Morton , Michal Hocko , David Rientjes , Johannes Weiner , Roman Gushchin , Minchan Kim , "Kirill A. Shutemov" , Andrea Arcangeli , Christian Brauner , Christoph Hellwig , Oleg Nesterov , David Hildenbrand , Jann Horn , Shakeel Butt , Peter Xu , John Hubbard , shuah@kernel.org, LKML , linux-mm , linux-kselftest@vger.kernel.org, kernel-team , Liam Howlett Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=bMFgFjuZ; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf20.hostedemail.com: domain of surenb@google.com designates 209.85.219.177 as permitted sender) smtp.mailfrom=surenb@google.com X-Stat-Signature: 6rrc91exd9m38so141paprnuq83gzrof X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: DCD591C0064 X-HE-Tag: 1654182165-61453 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, Jun 2, 2022 at 6:39 AM Matthew Wilcox wrote: > > On Wed, Jun 01, 2022 at 02:47:41PM -0700, Suren Baghdasaryan wrote: > > > Unclear why this patch fiddles with the mm_struct locking in this > > > fashion - changelogging that would have been helpful. > > > > Yeah, I should have clarified this in the description. Everything up > > to unmap_vmas() can be done under mmap_read_lock and that way > > oom-reaper and process_mrelease can do the unmapping in parallel with > > exit_mmap. That's the reason we take mmap_read_lock, unmap the vmas, > > mark the mm with MMF_OOM_SKIP and take the mmap_write_lock to execute > > free_pgtables. I think maple trees do not change that except there is > > no mm->mmap anymore, so the line at the end of exit_mmap where we > > reset mm->mmap to NULL can be removed (I show that line below). > > I don't understand why we _want_ unmapping to proceed in parallel? Is it > so urgent to unmap these page tables that we need two processes doing > it at the same time? And doesn't that just change the contention from > visible (contention on a lock) to invisible (contention on cachelines)? It's important for process_madvise() syscall not to be blocked by a potentially lower priority task doing exit_mmap. I've seen such priority inversion happening when the dying process is running on a little core taking its time while a high-priority task is waiting in the syscall while there is no reason for them to block each other. >