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.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 79E6FC0044D for ; Wed, 11 Mar 2020 22:04:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7A760206E7 for ; Wed, 11 Mar 2020 22:04:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A760206E7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=i-love.sakura.ne.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C1C816B0005; Wed, 11 Mar 2020 18:04:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BCD666B0006; Wed, 11 Mar 2020 18:04:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE3566B0007; Wed, 11 Mar 2020 18:04:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0098.hostedemail.com [216.40.44.98]) by kanga.kvack.org (Postfix) with ESMTP id 93D3E6B0005 for ; Wed, 11 Mar 2020 18:04:36 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 4AA132C0D for ; Wed, 11 Mar 2020 22:04:36 +0000 (UTC) X-FDA: 76584461352.20.car16_281683b8a0d1b X-HE-Tag: car16_281683b8a0d1b X-Filterd-Recvd-Size: 4211 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Mar 2020 22:04:35 +0000 (UTC) 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 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 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: >>>>> /* >>>>> >>>> >> >>