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 B36C2C433EF for ; Thu, 3 Mar 2022 07:48:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D01558D0002; Thu, 3 Mar 2022 02:48:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CB14E8D0001; Thu, 3 Mar 2022 02:48:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA02C8D0002; Thu, 3 Mar 2022 02:48:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id A74788D0001 for ; Thu, 3 Mar 2022 02:48:37 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C5576181B04B3 for ; Thu, 3 Mar 2022 07:48:35 +0000 (UTC) X-FDA: 79202297790.19.A69F607 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf14.hostedemail.com (Postfix) with ESMTP id 16890100003 for ; Thu, 3 Mar 2022 07:48:34 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 775E41F381; Thu, 3 Mar 2022 07:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1646293713; 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=+M2pNqHE/aOs6jr/fL87EioeI0y3A/KHNWJGqCoCUD8=; b=pX+XjyCUfQW5kB4qA25NsEQDvzQRSLFFlTDKAMkS2yp5RD1QYBkWrAO9n405sJviTesbKt urQ6rNtrV+G5cx/YpV2s2wJXtl7BsXEc6C6O/lYvfQ5w7mtLPmLEFgDG+TqDaaWqYKOoot HC20m7D9tEX9lf8VVr+f4m/H+Huc6L8= 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 4B0E2A3B81; Thu, 3 Mar 2022 07:48:28 +0000 (UTC) Date: Thu, 3 Mar 2022 08:48:32 +0100 From: Michal Hocko To: Nico Pache Cc: Waiman Long , linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, jsavitz@redhat.com, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, dvhart@infradead.org, dave@stgolabs.net, andrealmeid@collabora.com Subject: Re: [PATCH v3] mm/oom: do not oom reap task with an unresolved robust futex Message-ID: References: <20220114180135.83308-1-npache@redhat.com> <43a6c470-9fc2-6195-9a25-5321d17540e5@redhat.com> <118fc685-c68d-614f-006a-7d5487302122@redhat.com> <7f1ba14f-34e8-5f05-53b7-c12913693df8@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7f1ba14f-34e8-5f05-53b7-c12913693df8@redhat.com> X-Rspamd-Queue-Id: 16890100003 X-Stat-Signature: mantwn8tjo16uamdpeagk1n6f9hqh3jc X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=pX+XjyCU; spf=pass (imf14.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-Rspamd-Server: rspam07 X-HE-Tag: 1646293714-364086 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 Wed 02-03-22 12:26:45, Nico Pache wrote: > > > On 3/2/22 09:24, Michal Hocko wrote: > > Sorry, this has slipped through cracks. > > > > On Mon 14-02-22 15:39:31, Nico Pache wrote: > > [...] > >> We've recently been discussing the following if statement in __oom_reap_task_mm: > >> if (vma_is_anonymous(vma) || !(vma->vm_flags & VM_SHARED)) > >> > >> Given the comment above it, and some of the upstream discussion the original > >> RFC, we are struggling to see why this should be a `||` and not an `&&`. If we > >> only want to reap anon memory and reaping shared memory can be dangerous is this > >> statement incorrect? > >> > >> We have a patch queued up to make this change, but wanted to get your opinion on > >> why this was originally designed this way in case we are missing something. > > > > I do not really see why this would be wrong. Private file backed > > mappings can contain a reapable memory as well. I do not see how this > > would solve the futex issue. > We were basing our discussion around the following comment: > /* > * Only anonymous pages have a good chance to be dropped > * without additional steps which we cannot afford as we > * are OOM already. > * > * We do not even care about fs backed pages because all > * which are reclaimable have already been reclaimed and > * we do not want to block exit_mmap by keeping mm ref > * count elevated without a good reason. > */ > > So changing to an && would align the functionality with this comment by ignoring > fs backed pages, and additionally it prevents shared mappings from being reaped. > We have tested this change and found we can no longer reproduce the issue. In > our case we allocate the mutex on a MAP_SHARED|MAP_ANONYMOUS mmap so the if- > statement in question would no longer return true after the && change. > > If it is the case that private fs backed pages matter perhaps we want something > like this: > if ((vma_is_anonymous(vma) && !(vma->vm_flags & VM_SHARED)) > ||(!vma_is_anonymous(vma) && !(vma->vm_flags & VM_SHARED))) > > or more simply: > if(!(vma->vm_flags & VM_SHARED)) > > to exclude all VM_SHARED mappings. I would have to think about that some more but I do not really see how this is related to the futex issue. In other words what kind of problem does this solve? -- Michal Hocko SUSE Labs