Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp589876pxm; Thu, 3 Mar 2022 00:01:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgnw7tvyRr23l2GUYkiiWuhBLccImps0xVdhk+upkjZqe1FtEBI89EikNCtirzBr0v1lwu X-Received: by 2002:a17:902:9045:b0:14f:14e7:f3aa with SMTP id w5-20020a170902904500b0014f14e7f3aamr33451697plz.69.1646294468668; Thu, 03 Mar 2022 00:01:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646294468; cv=none; d=google.com; s=arc-20160816; b=G5pTqzyuF8SQCQbtTfvU7aKHZo3kA33cqOTTbK6h9Iax2BKXdNKEpwG4A40gHDDhIM Ir2EOtbRpy4H/d85tlXepRKheClOC4NO/YKhWR5QWpkDfKDuRPs2jYWRNFd8BlHJ8PNH gnMMVRtukogf19R/N47XkSxy3Y446E2ykjKrxvAVyxSZ/gBWcNed2a3LEdyNG1/Aip+q W2OOPFbKs0oDRxemtJHqrs/muWJaGyftmaUFZA1pGMVgfi+d+WH6NGklHdcskol+YxCY zl+BinMOzwxDSW/Dp8bYYhzqquLAhv193AnV8rL65JLbYNRqTStTpnTle5AGDzUKmgZH x9+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+M2pNqHE/aOs6jr/fL87EioeI0y3A/KHNWJGqCoCUD8=; b=KimqfjY5XVbHB86C+kDn5GpcdAPNT3+l16aZ61vwS+01mlZNdEGNSC/od8dbJgDv8O q9zH9/wQA17+1+BYIyzkEUSaMinJqNti23GTdNb3s83iL7nVF227jg1+tJ12Qvjoe5kB cMgOj2qY8eVjzDvupdELUcm5AbK/nZZ4BGlN3y8F9OP01tldVrKkysU1TGP7oXcLIosp Lh65xBHphqw4AQp2E4bEIhZiQcUBUGx+o1M8DhWw8zvspASKSsEaun2gooaCxncHV2z8 s1zzfcJZWNB2Y2z5nKECPoHYgkS06XjxsEYaj7noRxr3Sh3Sh3U0N6pLEr6nBqtmXNXM npCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=pX+XjyCU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e8-20020a056a001a8800b004f143b37018si1352182pfv.268.2022.03.03.00.00.50; Thu, 03 Mar 2022 00:01:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=pX+XjyCU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230204AbiCCHtW (ORCPT + 99 others); Thu, 3 Mar 2022 02:49:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbiCCHtU (ORCPT ); Thu, 3 Mar 2022 02:49:20 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3FB6674E3 for ; Wed, 2 Mar 2022 23:48:34 -0800 (PST) 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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