Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4291467imm; Mon, 30 Jul 2018 11:53:08 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeoFuOsyE9iIP/tjG6lgfD875pNgoD3WMC3deYRxpp8X/KxRJxAWLb2XxQo21mywqM+9B+U X-Received: by 2002:a62:229a:: with SMTP id p26-v6mr19094959pfj.53.1532976788507; Mon, 30 Jul 2018 11:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532976788; cv=none; d=google.com; s=arc-20160816; b=bbSrcvNeKx7wdzpw/x0UjOCwi3Z0x5elxyj7ZeRJzvP2G4mwVHeuRRTJwqC9yyskkK feasHsV2FyZlugos1DO7Atzd1LFgPPjizhN6grYw/5MkTaMIlwRd+uk1h8hbuU9xErzf X645e0T1BPIb/vqUlb/Lcgm93tD3/gjxg19WUATBzTKqQkG7GGG4XdTFDMizOUsOs2AV zKEn3RiujBniwaYJDjrkWinyx2eP8CotAkZP/VHxoKzrvajR6mPsBUFMfPOyaegkWpop uP/M7xhMkG2qgJSiq411FkOdEMpWEcXTnD9f4cWmo7/AkaV35a5A7bJkUpOOBAMYMkDF sFWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=3vr1ESi0U8kZj96MwIqCPJhCimIZphxyV2PGlsf4u7Q=; b=BgJU+uJGvk/blSIuR4HsySP0buvBvGPJMryq0o+fCGyj4dGLBd5JCTK9Gq6W/RSj0+ xFbn82uZHiuT4fgmLrQcbsbTr80QD3RDWI8PSBdDhl4hANp7bnzsk9mLKPtU09aRlMsv p9i5PsL+uBIjd/MBqXmbmFh06L5NEvHo0vdlRQW8CWL6eYDb3DdX7g/XGnckKyIS5lMx Xbpz+TDwris7RKD0LtFJvAk27dPolF4b8znxJWA+tYFdpp7zKdgMIBgiHTaC9UUgJWN5 /7KwvqdRxnIQBjtVKo6O3u8c9rjPOwTqI7dKpWWsf40xZk6F7BedKrLkOp9SCpidDPst +z/g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p9-v6si11484019pff.30.2018.07.30.11.52.54; Mon, 30 Jul 2018 11:53:08 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731941AbeG3U1c (ORCPT + 99 others); Mon, 30 Jul 2018 16:27:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:47538 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729561AbeG3U1c (ORCPT ); Mon, 30 Jul 2018 16:27:32 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7B2E9ADD9; Mon, 30 Jul 2018 18:51:11 +0000 (UTC) Date: Mon, 30 Jul 2018 20:51:10 +0200 From: Michal Hocko To: Tejun Heo Cc: Tetsuo Handa , Roman Gushchin , Johannes Weiner , Vladimir Davydov , David Rientjes , Andrew Morton , Linus Torvalds , linux-mm , LKML Subject: Re: [PATCH] mm,page_alloc: PF_WQ_WORKER threads must sleep at should_reclaim_retry(). Message-ID: <20180730185110.GB24267@dhcp22.suse.cz> References: <20180726113958.GE28386@dhcp22.suse.cz> <55c9da7f-e448-964a-5b50-47f89a24235b@i-love.sakura.ne.jp> <20180730093257.GG24267@dhcp22.suse.cz> <9158a23e-7793-7735-e35c-acd540ca59bf@i-love.sakura.ne.jp> <20180730144647.GX24267@dhcp22.suse.cz> <20180730145425.GE1206094@devbig004.ftw2.facebook.com> <0018ac3b-94ee-5f09-e4e0-df53d2cbc925@i-love.sakura.ne.jp> <20180730154424.GG1206094@devbig004.ftw2.facebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180730154424.GG1206094@devbig004.ftw2.facebook.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 30-07-18 08:44:24, Tejun Heo wrote: > Hello, > > On Tue, Jul 31, 2018 at 12:25:04AM +0900, Tetsuo Handa wrote: > > WQ_MEM_RECLAIM guarantees that "struct task_struct" is preallocated. But > > WQ_MEM_RECLAIM does not guarantee that the pending work is started as soon > > as an item was queued. Same rule applies to both WQ_MEM_RECLAIM workqueues > > and !WQ_MEM_RECLAIM workqueues regarding when to start a pending work (i.e. > > when schedule_timeout_*() is called). > > > > Is this correct? > > WQ_MEM_RECLAIM guarantees that there's always gonna exist at least one > kworker running the workqueue. But all per-cpu kworkers are subject > to concurrency limiting execution - ie. if there are any per-cpu > actively running on a cpu, no futher kworkers will be scheduled. Well, in the ideal world we would _use_ that pre-allocated kworker if there are no other available because they are doing something that takes a long time to accomplish. Page allocator can spend a lot of time if we are struggling to death to get some memory. > > > We can add timeout mechanism to workqueue so that it > > > kicks off other kworkers if one of them is in running state for too > > > long, but idk, if there's an indefinite busy loop condition in kernel > > > threads, we really should get rid of them and hung task watchdog is > > > pretty effective at finding these cases (at least with preemption > > > disabled). > > > > Currently the page allocator has a path which can loop forever with > > only cond_resched(). > > Yeah, workqueue can choke on things like that and kthread indefinitely > busy looping doesn't do anybody any good. Yeah, I do agree. But this is much easier said than done ;) Sure we have that hack that does sleep rather than cond_resched in the page allocator. We can and will "fix" it to be unconditional in the should_reclaim_retry [1] but this whole thing is really subtle. It just take one misbehaving worker and something which is really important to run will get stuck. That being said I will post the patch with updated changelog recording this. [1] http://lkml.kernel.org/r/ca3da8b8-1bb5-c302-b190-fa6cebab58ca@I-love.SAKURA.ne.jp -- Michal Hocko SUSE Labs