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 X-Spam-Level: X-Spam-Status: No, score=-5.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4896C433E1 for ; Fri, 21 Aug 2020 16:33:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8457620724 for ; Fri, 21 Aug 2020 16:33:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SDgorumr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8457620724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EB92D8D006C; Fri, 21 Aug 2020 12:33:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E8E6F8D0013; Fri, 21 Aug 2020 12:33:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA4A98D006C; Fri, 21 Aug 2020 12:33:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0097.hostedemail.com [216.40.44.97]) by kanga.kvack.org (Postfix) with ESMTP id C43938D0013 for ; Fri, 21 Aug 2020 12:33:23 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8D289363E for ; Fri, 21 Aug 2020 16:33:23 +0000 (UTC) X-FDA: 77175121086.18.need78_0e025502703a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 51C9D100ED0F8 for ; Fri, 21 Aug 2020 16:33:23 +0000 (UTC) X-HE-Tag: need78_0e025502703a X-Filterd-Recvd-Size: 4948 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Fri, 21 Aug 2020 16:33:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598027601; h=from:from:reply-to:subject:subject: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=71SIGIW8765UhVrcPeIzz5zqD/0d0YwU7JAOQ+5WuGI=; b=SDgorumrUkaPFP5Brf8UPMG2f4cpJNYAGl32rYaJlsz/RzDTPVy2I2NPUPVVIsi/wzudRU 7y8U3x8Y/R8wQz2cz+OxnXNlO8K53YYunNcOQTbZlCZkhyq7+lcl8yYVLAoayLETfzjDeo 5H7On6d+DCeH4Bl+hfJfohgKeD/uYvQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-323-w4fSooo0OPSM6XZNNgiiDQ-1; Fri, 21 Aug 2020 12:33:17 -0400 X-MC-Unique: w4fSooo0OPSM6XZNNgiiDQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A75128799EF; Fri, 21 Aug 2020 16:33:13 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.40.192.15]) by smtp.corp.redhat.com (Postfix) with SMTP id 7E8FF10013C4; Fri, 21 Aug 2020 16:33:02 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 21 Aug 2020 18:33:13 +0200 (CEST) Date: Fri, 21 Aug 2020 18:33:01 +0200 From: Oleg Nesterov To: Suren Baghdasaryan Cc: "Eric W. Biederman" , Michal Hocko , Tetsuo Handa , Christian Brauner , Tim Murray , mingo@kernel.org, Peter Zijlstra , Thomas Gleixner , esyr@redhat.com, christian@kellner.me, areber@redhat.com, Shakeel Butt , cyphar@cyphar.com, adobriyan@gmail.com, Andrew Morton , gladkov.alexey@gmail.com, Michel Lespinasse , daniel.m.jordan@oracle.com, avagin@gmail.com, bernd.edlinger@hotmail.de, John Johansen , laoar.shao@gmail.com, Minchan Kim , kernel-team , LKML , linux-fsdevel@vger.kernel.org, linux-mm Subject: Re: [PATCH 1/1] mm, oom_adj: don't loop through tasks in __set_oom_adj when not necessary Message-ID: <20200821163300.GB19445@redhat.com> References: <20200820133454.ch24kewh42ax4ebl@wittgenstein> <20200820140054.fdkbotd4tgfrqpe6@wittgenstein> <637ab0e7-e686-0c94-753b-b97d24bb8232@i-love.sakura.ne.jp> <87k0xtv0d4.fsf@x220.int.ebiederm.org> <20200820162645.GP5033@dhcp22.suse.cz> <87r1s0txxe.fsf@x220.int.ebiederm.org> <20200821111558.GG4546@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Rspamd-Queue-Id: 51C9D100ED0F8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 08/21, Suren Baghdasaryan wrote: > > On Fri, Aug 21, 2020 at 4:16 AM Oleg Nesterov wrote: > > > > bool probably_has_other_mm_users(tsk) > > { > > return atomic_read_acquire(&tsk->mm->mm_users) > > > atomic_read(&tsk->signal->live); > > } > > > > The barrier implied by _acquire ensures that if we race with the exiting > > task and see the result of exit_mm()->mmput(mm), then we must also see > > the result of atomic_dec_and_test(signal->live). > > > > Either way, if we want to fix the race with clone(CLONE_VM) we need other > > changes. > > The way I understand this condition in __set_oom_adj() sync logic is > that we would be ok with false positives (when we loop unnecessarily) > but we can't tolerate false negatives (when oom_score_adj gets out of > sync). Yes, > With the clone(CLONE_VM) race not addressed we are allowing > false negatives and IMHO that's not acceptable because it creates a > possibility for userspace to get an inconsistent picture. When > developing the patch I did think about using (p->mm->mm_users > > p->signal->nr_threads) condition and had to reject it due to that > reason. Not sure I understand... I mean, the test_bit(MMF_PROC_SHARED) you propose is equally racy and we need copy_oom_score() at the end of copy_process() either way? Oleg.