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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F7C0C433EF for ; Fri, 12 Nov 2021 08:58:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73B0F60FDA for ; Fri, 12 Nov 2021 08:58:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234698AbhKLJBB (ORCPT ); Fri, 12 Nov 2021 04:01:01 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:58914 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232841AbhKLJA6 (ORCPT ); Fri, 12 Nov 2021 04:00:58 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 9011721B19; Fri, 12 Nov 2021 08:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1636707486; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GkR05k/DFv96yXZ/lJqoljojL8CyJn6KLqBUIDP3Z+w=; b=a/xykZk+UMhhumwe44SfoAxX9MWc8wbnfDMF0R08z5/IQS52lnWPpK7SL4TDXXMo06fBtM NL1A653z0Tfn9EwjsKxwdqgMcF4/mLlNnsb5KJDRFfcKexusg610SfPsqoEs5B+lO5pfhn 99WTvZx3A9jR+QMYhgw9a2HhJVFWcn8= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 41233A3B81; Fri, 12 Nov 2021 08:58:06 +0000 (UTC) Date: Fri, 12 Nov 2021 09:58:05 +0100 From: Michal Hocko To: Suren Baghdasaryan Cc: 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 , Shakeel Butt , Andy Lutomirski , Christian Brauner , Florian Weimer , Jan Engelhardt , Linux API , linux-mm , LKML , kernel-team , "Kirill A. Shutemov" , Andrea Arcangeli Subject: Re: [PATCH 1/1] mm: prevent a race between process_mrelease and exit_mmap Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 11-11-21 07:02:42, Suren Baghdasaryan wrote: > On Thu, Nov 11, 2021 at 1:20 AM Michal Hocko wrote: > > > > On Wed 10-11-21 17:49:37, Suren Baghdasaryan wrote: > > > On Tue, Nov 9, 2021 at 1:10 PM Suren Baghdasaryan wrote: > > > > > > > > On Tue, Nov 9, 2021 at 12:10 PM Michal Hocko wrote: > > [...] > > > > > Yes, those can run concurrently. One thing I completely forgot about is > > > > > 27ae357fa82b ("mm, oom: fix concurrent munlock and oom reaper unmap, v3") > > > > > which is about interaction with the munlock. > > > > > > Agrh! This interaction with the munlock you mentioned requires us to > > > take mmap_write_lock before munlock_vma_pages_all and that prevents > > > __oom_reap_task_mm from running concurrently with unmap_vmas. The > > > reapers would not be as effective as they are now after such a change > > > :( > > > > __oom_reap_task_mm will not run concurrently with unmap_vmas even > > with the current code. The mmap_sem barrier right before munlock code > > prevents that. > > You are right, it will run concurrently with another > __oom_reap_task_mm in the exit_mmap. But I thought we wanted to get > rid of that call to __oom_reap_task_mm in exit_mmap or did I > misunderstand? I do not remember this to be objective or the motivation. IIRC we wanted to make the locking more robust which would help your process_mrelease use case. This one currently suffers from a much heavier cost if it turns out to be the last holder of the reference count on the address space. -- Michal Hocko SUSE Labs