Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp988577ybh; Wed, 11 Mar 2020 15:06:39 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvTyfsthdP2HpEVNvAIQbtsq6boZZAQQot+xANOmP0z+dni3uwgI8SpwbWuS4pP8Z4oOufn X-Received: by 2002:a05:6808:651:: with SMTP id z17mr540001oih.160.1583964399539; Wed, 11 Mar 2020 15:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583964399; cv=none; d=google.com; s=arc-20160816; b=mjZgCYZGPbv2Yli/tPsKzylR+7r+MFgVE1HdT8FNaAwV+6uJlOVpePiFAb70NBkGFo C14Ubl0I39g8kIdQUXNFzki3VNhg9ZjiRVxeHQ0USz4UFLupAsfR8J5gnWFT+Ad5f863 Z8aaSnQDUrWRDOoyFtFP3AA1t0eEp7OLkPUGjVRC7VZMHBZmqcLjZP3+enklehx7LgJD tRe5RUIetJZSIOOtgPLzZvEXZHDvWhASDaUtDCiOp3iKhDVTuD2BADfyBcwDlF7S2jo8 7IXYOdJnclz1gdMotXefYHPtJGUMxlyg3OSsgZnshE+2O+EP4x9cQ2uEY8RlDyh9cUFu exfg== 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; bh=hdXP5caLIdwG3YJdle71kQGrZrpbrzHN6hmfGMbPhjw=; b=q30tYJsJjzlx5+rj1+381FBof2jWJzK9Hh563v2vMAk3wKCrbtkAmtgsucB+RoVIaZ X1OQubDCapU4Fp7XLpkfep0d9D3T+W2e8gNKEzWBfUtWkKjzQ9LCGeSUmuGQnvEQDNhH sBlvtgqm+/Bc3s+a0EZPg+aq06vKMmtzcHaqMnJ7qbkp7m/jhF1H2XZTZXRCIt8gfF9d DXg70rOWcE9uD98yketY4+1Z2BsG5uZv4vyGZ6JqHedGFFeR7TbCt+ZQ+z9hKynINCCo VofI4dYKBBS+sJchbOGCyQprv0hoBaCRsYMa9fLe7D8jcK9AK91JEz1dEYRNzndMCQ0G cYwg== 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 w4si1624383oih.231.2020.03.11.15.06.27; Wed, 11 Mar 2020 15:06:39 -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 S1729629AbgCKWEo (ORCPT + 99 others); Wed, 11 Mar 2020 18:04:44 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:63006 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729223AbgCKWEo (ORCPT ); Wed, 11 Mar 2020 18:04:44 -0400 Received: from fsav109.sakura.ne.jp (fsav109.sakura.ne.jp [27.133.134.236]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 02BM4PjA051123; Thu, 12 Mar 2020 07:04:25 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav109.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav109.sakura.ne.jp); Thu, 12 Mar 2020 07:04:25 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav109.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 02BM4K9b051090 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 12 Mar 2020 07:04:25 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [patch] mm, oom: prevent soft lockup on memcg oom for UP systems To: David Rientjes Cc: Andrew Morton , Vlastimil Babka , Michal Hocko , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <0e5ca6ee-d460-db8e-aba2-79aa7a66fad1@I-love.SAKURA.ne.jp> <7a6170fc-b247-e327-321a-b99fb53f552d@i-love.sakura.ne.jp> From: Tetsuo Handa Message-ID: <993e7783-60e9-ba03-b512-c829b9e833fd@i-love.sakura.ne.jp> Date: Thu, 12 Mar 2020 07:04:20 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: 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 2020/03/12 4:38, David Rientjes wrote: > On Wed, 11 Mar 2020, Tetsuo Handa wrote: > >>>>> diff --git a/mm/vmscan.c b/mm/vmscan.c >>>>> --- a/mm/vmscan.c >>>>> +++ b/mm/vmscan.c >>>>> @@ -2637,6 +2637,8 @@ static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc) >>>>> unsigned long reclaimed; >>>>> unsigned long scanned; >>>>> >>>>> + cond_resched(); >>>>> + >>>> >>>> Is this safe for CONFIG_PREEMPTION case? If current thread has realtime priority, >>>> can we guarantee that the OOM victim (well, the OOM reaper kernel thread rather >>>> than the OOM victim ?) gets scheduled? >>>> >>> >>> I think it's the best we can do that immediately solves the issue unless >>> you have another idea in mind? >> >> "schedule_timeout_killable(1) outside of oom_lock" or "the OOM reaper grabs oom_lock >> so that allocating threads guarantee that the OOM reaper gets scheduled" or "direct OOM >> reaping so that allocating threads guarantee that some memory is reclaimed". >> > > The cond_resched() here is needed if the iteration is lengthy depending on > the number of descendant memcgs already. No. cond_resched() here will become no-op if CONFIG_PREEMPTION=y and current thread has realtime priority. > > schedule_timeout_killable(1) does not make any guarantees that current > will be scheduled after the victim or oom_reaper on UP systems. The point of schedule_timeout_*(1) is to guarantee that current thread will yield CPU to other threads even if CONFIG_PREEMPTION=y and current thread has realtime priority case. There is no guarantee that current thread will be rescheduled immediately after a sleep is irrelevant. > > If you have an alternate patch to try, we can test it. But since this > cond_resched() is needed anyway, I'm not sure it will change the result. schedule_timeout_killable(1) is an alternate patch to try; I don't think that this cond_resched() is needed anyway. > >>> >>>>> switch (mem_cgroup_protected(target_memcg, memcg)) { >>>>> case MEMCG_PROT_MIN: >>>>> /* >>>>> >>>> >> >>