Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2007774imm; Thu, 2 Aug 2018 04:55:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfZhZzWC4nHvM4aGrcq7lMKYtNzGFqygYf4bGqt1jnZ7a+5jTGx0c2tC7RbEEpYcwao2RJw X-Received: by 2002:a63:710d:: with SMTP id m13-v6mr2474565pgc.66.1533210905026; Thu, 02 Aug 2018 04:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533210905; cv=none; d=google.com; s=arc-20160816; b=wSRCrAshBOmrHiN3Gl0dskMRT0hj2o4fLLjGA5NAOGyh3TXNMNfqbLfW7G8DthfwBn U00qKPWpLNPvMQwvz8zTukYL9FaiXa6N8wBzT9aPEq9A5nlNU4FSVGAd6F80ODnrFnVq xX6Hwlj5IpaVQ+9N1zXUWIPCF4SB8qWUb/6Xx4L6pUA7N2YtFGGfBvmvHIrwSQPyG1mv qZFaDt0YVm6LUsjFBjgaPj4tzJzALyU8vSuptjEYLcUd/OVg287c3xAwsK7Rw29y6sPC 8YrbzkhfOqyPQMnX+K0gZMabcxgfSO0exo0FL06qul7lAB6sMl0cKyKzpgdy2GHqob8F wp7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=g9386ahXL6q6LR9Jis2DD225nBjQoHNdl6eK+o72mmg=; b=AYCFobLU/0nGtDF9qMGflQ0MtaUyJrYPSo6sGW9F/KeAvmS5Ww9vWre06HckbSXCcx jQO5CWgx5wcY9unFzkdNIHzFc/+RMEdM7DvuaSiZXK6Z1pXDUwmNi5cdIp5IXi3IwRz7 eZ97ZUiLm7BpJKYB7P0kqQqCDc/vHvQyLQzymENu4KRndNsbcnjK0Lv4FANhtjK/O/oH 74l3qdl+eH3c+y2esd7fAxo1YiVkFPRKGEgj/WdmfUdfDOmdRT/Ol0ai9/V8eiaY602n Q89bpaPSkNcqLo8E8Yl05DGE34w2h4lVEq4OZ4JnvNDNuk9AwYgZHKjo05YpKiMAXYdE amfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z20-v6si2060279pfj.337.2018.08.02.04.54.49; Thu, 02 Aug 2018 04:55:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732279AbeHBNoO (ORCPT + 99 others); Thu, 2 Aug 2018 09:44:14 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:62448 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729460AbeHBNoO (ORCPT ); Thu, 2 Aug 2018 09:44:14 -0400 Received: from fsav401.sakura.ne.jp (fsav401.sakura.ne.jp [133.242.250.100]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w72BrM44096101; Thu, 2 Aug 2018 20:53:22 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav401.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav401.sakura.ne.jp); Thu, 02 Aug 2018 20:53:22 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav401.sakura.ne.jp) Received: from [192.168.1.8] (softbank126074194044.bbtec.net [126.74.194.44]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w72BrHsH096055 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 2 Aug 2018 20:53:22 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [PATCH v2 3/3] mm, oom: introduce memory.oom.group To: Michal Hocko Cc: Roman Gushchin , linux-mm@kvack.org, Johannes Weiner , David Rientjes , Tejun Heo , kernel-team@fb.com, linux-kernel@vger.kernel.org References: <20180802003201.817-1-guro@fb.com> <20180802003201.817-4-guro@fb.com> <879f1767-8b15-4e83-d9ef-d8df0e8b4d83@i-love.sakura.ne.jp> <20180802112114.GG10808@dhcp22.suse.cz> From: Tetsuo Handa Message-ID: <712a319f-c9da-230a-f2cb-af980daff704@i-love.sakura.ne.jp> Date: Thu, 2 Aug 2018 20:53:14 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180802112114.GG10808@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/08/02 20:21, Michal Hocko wrote: > On Thu 02-08-18 19:53:13, Tetsuo Handa wrote: >> On 2018/08/02 9:32, Roman Gushchin wrote: > [...] >>> +struct mem_cgroup *mem_cgroup_get_oom_group(struct task_struct *victim, >>> + struct mem_cgroup *oom_domain) >>> +{ >>> + struct mem_cgroup *oom_group = NULL; >>> + struct mem_cgroup *memcg; >>> + >>> + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) >>> + return NULL; >>> + >>> + if (!oom_domain) >>> + oom_domain = root_mem_cgroup; >>> + >>> + rcu_read_lock(); >>> + >>> + memcg = mem_cgroup_from_task(victim); >> >> Isn't this racy? I guess that memcg of this "victim" can change to >> somewhere else from the one as of determining the final candidate. > > How is this any different from the existing code? We select a victim and > then kill it. The victim might move away and won't be part of the oom > memcg anymore but we will still kill it. I do not remember this ever > being a problem. Migration is a privileged operation. If you loose this > restriction you shouldn't allow to move outside of the oom domain. The existing code kills one process (plus other processes sharing mm if any). But oom_cgroup kills multiple processes. Thus, whether we made decision based on correct memcg becomes important. > >> This "victim" might have already passed exit_mm()/cgroup_exit() from do_exit(). > > Why does this matter? The victim hasn't been killed yet so if it exists > by its own I do not think we really have to tear the whole cgroup down. The existing code does not send SIGKILL if find_lock_task_mm() failed. Who can guarantee that the victim is not inside do_exit() yet when this code is executed?