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 8CAD3C433F5 for ; Tue, 10 May 2022 20:59:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF5476B0071; Tue, 10 May 2022 16:59:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E7D7F6B0072; Tue, 10 May 2022 16:59:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF6866B0073; Tue, 10 May 2022 16:59:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B94BE6B0071 for ; Tue, 10 May 2022 16:59:38 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 8CCEA12191B for ; Tue, 10 May 2022 20:59:38 +0000 (UTC) X-FDA: 79451049636.02.E53210C Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by imf22.hostedemail.com (Postfix) with ESMTP id 5F5AAC00A7 for ; Tue, 10 May 2022 20:59:36 +0000 (UTC) Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-2fb965b34easo43097b3.1 for ; Tue, 10 May 2022 13:59:37 -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=G/q1rnQgMaznZ39ohQawlR0ZCKw+W7Y1nNqJrW+4o7o=; b=CALL3wkEY3b86p74iYDdbhQTNr+tfRN+V98GpzavNOy6JN9bP1wPMlvHcih2J5MHMc 8UGV/cPauPf41smjoWpJxvopoB6PaFtAoOLgCpClh6zk3izJT46mVl3grrPpDC8EDDeY Bx6n/EGn3sDgVj9MIcL7s0E82t1JbVt9MggqOzhw3XYkYzw75HFiblNjqMFBj0RJTfrg plh1lz39Zr+P/736TPlKm6vNE2zQTSW7iRYz1ysagi0v5o4Sm/wzrCY+zuc2Tm8rVz7/ QXM70R2/dAzJJoJ2DxyfEpQes++QZ+l2WknycT53cdHFtC2V7dTCZwQCGb6DLFccDyHL r2tg== 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=G/q1rnQgMaznZ39ohQawlR0ZCKw+W7Y1nNqJrW+4o7o=; b=XxzBJ0bbmVbphyh9UXcVYhxbMkA/S845evMs22IaZNwST2ywM1BJaWwq0ciqG8EIXV 7LPsUyBUoXTvuLYcnieCGmiXUtftMeTYCYolrF9kGBXvEEzmXJH2eZFgHuIIX9p/FH8F uXjLenIiVTOZneOPP61BJ7Ns5JEaLdndRiYg3ArsoSvyfBVXL5DWymEUHkEllYjT3inp c9TyFQFHP7t9Nop9acFWhHyvHXDGWkpXfTzgXeBCg6FNG4rtwMe3nNq0Sf9vsI+I9k+b Qq7v2E3dSDME7CXrpnQPemD4PbBcOjvsr5ntHvPKeqAyDaY0GZOsAZd8jl7+U95bSoqE Xlvg== X-Gm-Message-State: AOAM531mpv38kacnOYMAwQGqOhdj7jKjo+5i6tPYhwWeNqUVyOO02kmK ZoCB07to2G9+h2+FDxokhUljlF+CboxTLxcCzXK2qQ== X-Google-Smtp-Source: ABdhPJwBQdouaCTQjdwS7J9yFY1kM4uCTbuDjL2AFdvllvzNydU7sRdMGZkZEeIDKL8Y59rkE1t1nwb9SMkkRXYb+5c= X-Received: by 2002:a81:6cc3:0:b0:2f7:cc1f:b52d with SMTP id h186-20020a816cc3000000b002f7cc1fb52dmr21862524ywc.293.1652216377129; Tue, 10 May 2022 13:59:37 -0700 (PDT) MIME-Version: 1.0 References: <20220510030014.3842475-1-surenb@google.com> <20220510030014.3842475-2-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Tue, 10 May 2022 13:59:26 -0700 Message-ID: Subject: Re: [PATCH 2/3] mm: drop oom code from exit_mmap To: Michal Hocko Cc: Andrew Morton , David Rientjes , Matthew Wilcox , 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 Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 5F5AAC00A7 X-Stat-Signature: zq8wmt176xjo3tfo74kybf9fz5opou4f X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=CALL3wkE; spf=pass (imf22.hostedemail.com: domain of surenb@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam09 X-HE-Tag: 1652216376-351554 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 Tue, May 10, 2022 at 1:53 PM Michal Hocko wrote: > > On Tue 10-05-22 09:31:50, Suren Baghdasaryan wrote: > > On Tue, May 10, 2022 at 6:06 AM Michal Hocko wrote: > > > > > > On Mon 09-05-22 20:00:13, Suren Baghdasaryan wrote: > > > > With the oom-killer being able to operate on locked pages, exit_mmap > > > > does not need to ensure that oom_reap_task_mm is done before it can > > > > proceed. Instead it can rely on mmap_lock write lock to prevent > > > > oom-killer from operating on the vma tree while it's freeing page > > > > tables. exit_mmap can hold mmap_lock read lock when unmapping vmas > > > > and then take mmap_lock write lock before freeing page tables. > > > > > > The changelog is rather light on nasty details which might be good but > > > for the sake of our future us let's be more verbose so that we do not > > > have to reinvent the prior history each time we are looking into this > > > code. I would go with something like this instead: > > > " > > > The primary reason to invoke the oom reaper from the exit_mmap path used > > > to be a prevention of an excessive oom killing if the oom victim exit > > > races with the oom reaper (see 212925802454 ("mm: oom: let oom_reap_task > > > and exit_mmap run concurrently") for more details. The invocation has > > > moved around since then because of the interaction with the munlock > > > logic but the underlying reason has remained the same (see 27ae357fa82b > > > ("mm, oom: fix concurrent munlock and oom reaper unmap, v3"). > > > > > > Munlock code is no longer a problem since a213e5cf71cb ("mm/munlock: > > > delete munlock_vma_pages_all(), allow oomreap") and there shouldn't be > > > any blocking operation before the memory is unmapped by exit_mmap so > > > the oom reaper invocation can be dropped. The unmapping part can be done > > > with the non-exclusive mmap_sem and the exclusive one is only required > > > when page tables are freed. > > > > > > Remove the oom_reaper from exit_mmap which will make the code easier to > > > read. This is really unlikely to make any observable difference although > > > some microbenchmarks could benefit from one less branch that needs to be > > > evaluated even though it almost never is true. > > > " > > > > Looks great! Thanks for collecting all the history. Will update the description. > > Please make sure you double check the story. This is mostly my > recollection and brief reading through the said commits. I might > misremember here and there. Will do. Thanks! > -- > Michal Hocko > SUSE Labs