Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5473410ybl; Tue, 27 Aug 2019 05:21:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzZEUQv0tAGYvdE/kOAUDXun5danWuUHI/rUq5yZNVRKTOXmBwOCgma4+Mo3WGfO8Vqbwg X-Received: by 2002:a63:d04e:: with SMTP id s14mr20068017pgi.189.1566908486744; Tue, 27 Aug 2019 05:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566908486; cv=none; d=google.com; s=arc-20160816; b=MZfCeZAoZ6j7FLEMCrXkkOZJBWqPdQcOzRaDunB80v6xrgYh+avqKR28VGc4x/jSDG A9XEt9HaIvYBSe0lGRWCXxAIQlhTuOB1C+1N7iqWT1011nMUQQs1gjYHk5BrBKQFWYri q+7G1TI5EzjGHhI0fOH5xfHHD6vjCQAJxqjfKwMV41TREiZiHh/gkE4gEYEeNGjTK/IF zDKxfg1VFN+FbMX4Nm8d02cma2RU88yROyqscMdLsHiu9rJyTyLHjdpiOFt9p+RATKXt 1pydlPo0qCvJGCgu3QUvuW9Ij2sedWc1zwLPSEECEqCm6/aay6CUUzUekidMxoUvl62N mTaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=JZZ/56kClmUu9u3Lz2o/WyytqKT9LHvtxY62+NNR8z4=; b=sMP1UYrab5kXFxOm+ZlRhvxGdck5RuDnnGMQnNVPEAm6gLVujMdI3KUXu4ucJ4Mz1s JpY7Xk8Muq5f+X2lWoX2gL2840kHia4RX3N5UEAZL99qCv7pZVVb5Zk23vybaXxSEDqV fMahumZU9VRPzlT6lMO6xU0F+Pum2UQEplpVS8+81N5Ju3HkEDIbAdUzdXJmsHmBIRqt j/ng7O/LLInPwZTguTb7eZwQsWCno4K+uke/TT7/unKSDZKX2jh+Fr3FJiQ5Mg6Ol/WV 1sTPFE4XCec+6W9MnG3pKmFxX4TrV3+F6A2dQGkw799m0XJf2m+ozEnltOvZ8Xq9nz5E igEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KVtpiXX+; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97si12711721pld.245.2019.08.27.05.21.11; Tue, 27 Aug 2019 05:21:26 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KVtpiXX+; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729713AbfH0MUM (ORCPT + 99 others); Tue, 27 Aug 2019 08:20:12 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:40830 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726170AbfH0MUL (ORCPT ); Tue, 27 Aug 2019 08:20:11 -0400 Received: by mail-io1-f66.google.com with SMTP id t6so45779738ios.7 for ; Tue, 27 Aug 2019 05:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JZZ/56kClmUu9u3Lz2o/WyytqKT9LHvtxY62+NNR8z4=; b=KVtpiXX+jnNmjybRAgMq/v2UaZwJ8TQxwMhdPAdIblUW3hTj5KDbNBE+1U8XZrrqsD bvaBfzdSJd4O6jptxaZwR3veMwyukJ6IK/y9Oapht5+UPyYAcCfUpf/scv+s7NsBo8E9 HHshJMGjEUwMyfZKGrBij9V+05AyT+6LD2+CYd/ELmgrnLDbigilxr759mZYDFLJUijN lTafxftfeIz+n2j45oT3V/WlfqrQ9YtsdZfe0aXUV38hqqetZw1YVglXySEVouRtR/nA xPuhta6YMWXVVN1R4GxNy0k1DADS4JvbLj9Bvq6vCV8Q0xR8QdQT/RC3+QOYg+nUbKs3 6v/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JZZ/56kClmUu9u3Lz2o/WyytqKT9LHvtxY62+NNR8z4=; b=gGKiTc0+hHBWjgCLF/OJY2VU1KfnKgCkrxOWrqv8tIcyvx+me4NsZd/EUpO2cUD4u2 zNzJ1uYcN/U0+ITPMZ4zzCQe/3J6OyS9aVG5Lcyk2qZD33n0wEt4Jq50xUysdpPCRaq2 ygiETtWy7LV3E87lbL4PuopaURfs2efiFEbmTz7Mn2KnqJ0hv554jDtBc/iij4hDetwn roGKB1D7Tz4LVYD6iOINsYM07rAg472/SYfr94kK7r7O83sFCzJ+zrow6NdPtIO44in3 4rmHYQAoQ1wQniwT0p6KnwaT5w/IAWazXkJBebO//ZPyMCXT4BPDvW5REW69DkMX0iO+ M0bA== X-Gm-Message-State: APjAAAXIBK3iLpvQcqF7mPpL/EU1vdlkSi2AnDxuKYnWOqHacNIinfia fMT9i6g424PYGiCpaGlOrO5bmescVGU9AsVlFII= X-Received: by 2002:a6b:c38f:: with SMTP id t137mr8388942iof.137.1566908410262; Tue, 27 Aug 2019 05:20:10 -0700 (PDT) MIME-Version: 1.0 References: <20190826105521.GF7538@dhcp22.suse.cz> <20190827104313.GW7538@dhcp22.suse.cz> <20190827115014.GZ7538@dhcp22.suse.cz> <20190827120335.GA7538@dhcp22.suse.cz> In-Reply-To: <20190827120335.GA7538@dhcp22.suse.cz> From: Yafang Shao Date: Tue, 27 Aug 2019 20:19:34 +0800 Message-ID: Subject: Re: WARNINGs in set_task_reclaim_state with memory cgroup and full memory usage To: Michal Hocko Cc: Yang Shi , Adric Blake , Andrew Morton , Kirill Tkhai , Johannes Weiner , Daniel Jordan , Mel Gorman , Linux MM , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 27, 2019 at 8:03 PM Michal Hocko wrote: > > On Tue 27-08-19 19:56:16, Yafang Shao wrote: > > On Tue, Aug 27, 2019 at 7:50 PM Michal Hocko wrote: > > > > > > On Tue 27-08-19 19:43:49, Yafang Shao wrote: > > > > On Tue, Aug 27, 2019 at 6:43 PM Michal Hocko wrote: > > > > > > > > > > If there are no objection to the patch I will post it as a standalong > > > > > one. > > > > > > > > I have no objection to your patch. It could fix the issue. > > > > > > > > I still think that it is not proper to use a new scan_control here as > > > > it breaks the global reclaim context. > > > > > > > > This context switch from global reclaim to memcg reclaim is very > > > > subtle change to the subsequent processing, that may cause some > > > > unexpected behavior. > > > > > > Why would it break it? Could you be more specific please? > > > > > > > Hmm, I have explained it when replying to Hillf's patch. > > The most suspcious one is settting target_mem_cgroup here, because we > > only use it to judge whether it is in global reclaim. > > While the memcg softlimit reclaim is really in global reclaims. > > But we are reclaim the target_mem_cgroup hierarchy. This is the whole > point of the soft reclaim. Push down that hierarchy below the configured > limit. And that is why we absolutely have to switch the reclaim context. > One obvious issue is the reclaim couters may not correct. See shrink_inactive_list(). The pages relcaimed in memcg softlimit will not be counted to PGSCAN_{DIRECT, KSWAPD} and PGSTEAL_{DIRECT, KSWAPD}. That may cause some misleading. For example, if these counters are not changed, we will think that direct relcaim doesn't occur, while it really occurs. May issues are also in some other code around the usage of global_reclaim(). I'm not sure of it. > > Another example the reclaim_idx, if is not same with reclaim_idx in > > page allocation context, the reclaimed pages may not be used by the > > allocator, especially in the direct reclaim. > > Again, we do not care about that as well. All we care about is to > reclaim _some_ memory to get below the soft limit. This is the semantic > that is not really great but this is how the Soft reclaim has > traditionally worked and why we keep claiming that people shouldn't > really use it. It does lead to over reclaim and that is a design rather > than a bug. > > > And some other things in scan_control. > > Like? > -- > Michal Hocko > SUSE Labs >