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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70982C433FE for ; Wed, 27 Oct 2021 12:06:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1FE04610A0 for ; Wed, 27 Oct 2021 12:06:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1FE04610A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id B24B880007; Wed, 27 Oct 2021 08:06:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC714940007; Wed, 27 Oct 2021 08:06:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B65280007; Wed, 27 Oct 2021 08:06:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0022.hostedemail.com [216.40.44.22]) by kanga.kvack.org (Postfix) with ESMTP id 900C3940007 for ; Wed, 27 Oct 2021 08:06:03 -0400 (EDT) Received: from smtpin33.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 528CC18179035 for ; Wed, 27 Oct 2021 12:06:03 +0000 (UTC) X-FDA: 78742089006.33.EA40D1B Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by imf04.hostedemail.com (Postfix) with ESMTP id C7BC05000306 for ; Wed, 27 Oct 2021 12:05:57 +0000 (UTC) Received: by mail-qk1-f173.google.com with SMTP id br18so2160258qkb.1 for ; Wed, 27 Oct 2021 05:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VoE64TdDHE/gTi4i1OPzPbdXPkSP+qVI54kwUIQ+eMk=; b=IL0EkEfTynBQCNxlnvNvzTzem+gKVqgjCVzXu6qnPdM6ZilL8MkGt4o4Ddpv7trMUc 7ZhV1rgfVCaEBB/5+qfyGBTO9WtyfLu+qE2oHhSfi035eexUaoGgs20Ixveg9dENzZiH dx8ziwaUOl437AW0D+yLzqZL7iEEfJT4JbQEeMJmW3XuMOCKuJOksag2Uj5pH/nThtLy LR2IpXLI29hR+NZIOIJyOw5C+nH3L1e9QehG2CgerWvmKUmn2CanVHKyHvaq/ppvzB8Q sJq5aEjEuwSoAeMxleegWgF5aC1Lgs/h56TgGX8rMI+haT5XglBr9Jbi07SCygJN0W6+ 1cfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VoE64TdDHE/gTi4i1OPzPbdXPkSP+qVI54kwUIQ+eMk=; b=8NwTwWEawcCBH+aKndDtCJ3rZ35x4A+Y7ygDludaUojL7owkGhoXvZu3g25gaodWJY t+fVNpDjm3KBvp+uyWi5iw7UGhc8VNFubcUndim3J7evGdT8qnFGOInr3dmSQDgnZt92 5BDFAq/AJQ47o0uB5liD4/a/AkvgcpGyA6PCWefJEONoYa4TIPZCfWeTTPyiKXz0/QPe 2fPHEjJL4LgTRs/l4tMovJr4VQL+jKJ3+flc7oJvuBxjDqsRbg36XAeu96NHt898cmry +DGlopLmg0T+2PjsxiX32rDPmBKt1iQB18RILmilSzT9vnANuUt07Xu4XfdCVWyW/xkK TnBA== X-Gm-Message-State: AOAM531lUpwxmNNdYu/vCHcI7HjHmaz7lOD4+egMMos/s+VgiU4Cwf2t pST86tj6GjmB/cBI4fSViTJUTV7vLtZFFeBUKXk= X-Google-Smtp-Source: ABdhPJyhqfwnEgb39Ng1knA6fOpJFQOuh8egGkFLxlZkWZXZUn+IfcHlyFrRUSJ0dOT/K19Gv+5XOteNZnsroLbUHy4= X-Received: by 2002:a37:8e44:: with SMTP id q65mr23327968qkd.372.1635336351853; Wed, 27 Oct 2021 05:05:51 -0700 (PDT) MIME-Version: 1.0 References: <1635318110-1905-1-git-send-email-huangzhaoyang@gmail.com> In-Reply-To: From: Zhaoyang Huang Date: Wed, 27 Oct 2021 20:05:30 +0800 Message-ID: Subject: Re: [RFC PATCH] mm: have kswapd only reclaiming use min protection on memcg To: Michal Hocko Cc: Andrew Morton , Johannes Weiner , Vladimir Davydov , Zhaoyang Huang , "open list:MEMORY MANAGEMENT" , LKML Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: ptdhscawpsu957ewt1ssm1jbc8wpnyd7 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=IL0EkEfT; spf=pass (imf04.hostedemail.com: domain of huangzhaoyang@gmail.com designates 209.85.222.173 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C7BC05000306 X-HE-Tag: 1635336357-715332 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 Wed, Oct 27, 2021 at 7:52 PM Michal Hocko wrote: > > On Wed 27-10-21 17:19:56, Zhaoyang Huang wrote: > > On Wed, Oct 27, 2021 at 4:26 PM Michal Hocko wrote: > > > > > > On Wed 27-10-21 15:46:19, Zhaoyang Huang wrote: > > > > On Wed, Oct 27, 2021 at 3:20 PM Michal Hocko wrote: > > > > > > > > > > On Wed 27-10-21 15:01:50, Huangzhaoyang wrote: > > > > > > From: Zhaoyang Huang > > > > > > > > > > > > For the kswapd only reclaiming, there is no chance to try again on > > > > > > this group while direct reclaim has. fix it by judging gfp flag. > > > > > > > > > > There is no problem description (same as in your last submissions. Have > > > > > you looked at the patch submission documentation as recommended > > > > > previously?). > > > > > > > > > > Also this patch doesn't make any sense. Both direct reclaim and kswapd > > > > > use a gfp mask which contains __GFP_DIRECT_RECLAIM (see balance_pgdat > > > > > for the kswapd part).. > > > > ok, but how does the reclaiming try with memcg's min protection on the > > > > alloc without __GFP_DIRECT_RECLAIM? > > > > > > I do not follow. There is no need to protect memcg if the allocation > > > request doesn't have __GFP_DIRECT_RECLAIM because that would fail the > > > charge if a hard limit is reached, see try_charge_memcg and > > > gfpflags_allow_blocking check. > > > > > > Background reclaim, on the other hand never breaches reclaim protection. > > > > > > What is the actual problem you want to solve? > > Imagine there is an allocation with gfp_mask & ~GFP_DIRECT_RECLAIM and > > all processes are under cgroups. Kswapd is the only hope here which > > however has a low efficiency of get_scan_count. I would like to have > > kswapd work as direct reclaim in 2nd round which will have > > protection=memory.min. > > Do you have an example where this would be a practical problem? Atomic > allocations should be rather rare. Please find below for the search result of '~__GFP_DIRECT_RECLAIM' which shows some drivers and net prefer to behave like that. Furthermore, the allocations are always together with high order. block/bio.c:464: gfp_mask &= ~__GFP_DIRECT_RECLAIM; drivers/vhost/net.c:668: pfrag->page = alloc_pages((gfp & ~__GFP_DIRECT_RECLAIM) | drivers/net/ethernet/mellanox/mlx4/icm.c:184: mask &= ~__GFP_DIRECT_RECLAIM; fs/erofs/zdata.c:243: gfp_t gfp = (mapping_gfp_mask(mc) & ~__GFP_DIRECT_RECLAIM) | fs/fscache/page.c:138: gfp &= ~__GFP_DIRECT_RECLAIM; fs/fscache/cookie.c:187: INIT_RADIX_TREE(&cookie->stores, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); fs/btrfs/disk-io.c:2928: INIT_RADIX_TREE(&fs_info->reada_tree, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); fs/btrfs/volumes.c:6868: INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); fs/btrfs/volumes.c:6869: INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); kernel/cgroup/cgroup.c:325: ret = idr_alloc(idr, ptr, start, end, gfp_mask & ~__GFP_DIRECT_RECLAIM); mm/mempool.c:389: gfp_temp = gfp_mask & ~(__GFP_DIRECT_RECLAIM|__GFP_IO); mm/hugetlb.c:2165: gfp &= ~(__GFP_DIRECT_RECLAIM | __GFP_NOFAIL); mm/mempolicy.c:2061: preferred_gfp &= ~(__GFP_DIRECT_RECLAIM | __GFP_NOFAIL); mm/memcontrol.c:5452: ret = try_charge(mc.to, GFP_KERNEL & ~__GFP_DIRECT_RECLAIM, count); net/core/sock.c:2623: pfrag->page = alloc_pages((gfp & ~__GFP_DIRECT_RECLAIM) | net/core/skbuff.c:6084: page = alloc_pages((gfp_mask & ~__GFP_DIRECT_RECLAIM) | net/netlink/af_netlink.c:1302: (allocation & ~__GFP_DIRECT_RECLAIM) | net/netlink/af_netlink.c:2259: (GFP_KERNEL & ~__GFP_DIRECT_RECLAIM) | > > -- > Michal Hocko > SUSE Labs