From patchwork Thu Dec 28 06:27:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haifeng Xu X-Patchwork-Id: 183644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1834117dyb; Wed, 27 Dec 2023 22:28:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1DQde4jZl9q1yr0VXVF9Wa70tmVIRHPXnLEZ4hmzGjJK+fzhO+pdZ+WMIXtNVPtg3rPcV X-Received: by 2002:a05:6808:398a:b0:3bb:bfa5:320c with SMTP id gq10-20020a056808398a00b003bbbfa5320cmr4607768oib.116.1703744882836; Wed, 27 Dec 2023 22:28:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703744882; cv=none; d=google.com; s=arc-20160816; b=wemQnjXayJ0a0uZZFEXTueo+0QyVo6nSCQlFEpbLBGiC81/yKEj7scylJFrFt9YvjX L7Kw6KsHhTO5Ox7YS+Vizs4+spRluqlizG9OVVGIDzJLeBpMCv88iJ2MiJaqBydbINoy ENaF4mrG0mpdse4S+CgIYXfhwuH3AcGGhkjdl8vKDXqpm+lmdl72/z8SFhhpq7B9u3dG KXK6B4PW9xYhMwahesZi3JG5uPrJMAH3j3tv7wIACjmqFAbnbjO9FJ4c37GK9g51f1id NNVybxWB8pg6HovovXyTFansx3FTmSoKiJ44N3iY1XaTs3TSRZZa3nxCf9PzbnxUNWfZ zg1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=ezcMWpqhmHAMLrYn0+Q9MY7X5OW7VKM8sl5WwMShxTE=; fh=pfOfK6fK5+onSwSyJBXnd63HJvzPImPyoGOtiqyyjLE=; b=y1VxO5rlm2/BLpILhoSyuA2L4dQtt4Jq2EVb8uYZPpRR+O4Jq6PifzMBy5COJVuGWI yRy7lSgzdwSLgOsxiP6Isr8pvlzNyfYhugDgOxkjz/EhAapkaiyNwesAcaj5uDMIrj3O IVcoVorac5V02bZJRpUTsAoDI45WP3P6MxfVO1JGUVMJM7tt/T6JxAWBHX0u2ltxYYCV ZkuUeuE62w4/zIR190K42WoekBqO9snWx8BamGwePvZAhUQTI43WaR9ZVfRQewC7o1q1 RWOK6UOCzlBX7XUNwC2t+4j+0V8F+oM9+PmhLa4bSw1U+2wfL4d1Y1HmxBmwLNPyFYXP phjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shopee.com header.s=shopee.com header.b="JAw+/nS9"; spf=pass (google.com: domain of linux-kernel+bounces-12457-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12457-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=shopee.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n26-20020a056a000d5a00b006d9af0532a0si7549843pfv.41.2023.12.27.22.28.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 22:28:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12457-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@shopee.com header.s=shopee.com header.b="JAw+/nS9"; spf=pass (google.com: domain of linux-kernel+bounces-12457-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12457-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=shopee.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8C7B62834C1 for ; Thu, 28 Dec 2023 06:28:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0ED25689; Thu, 28 Dec 2023 06:27:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b="JAw+/nS9" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 836043C0E for ; Thu, 28 Dec 2023 06:27:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shopee.com Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6da67ca9969so4502788a34.1 for ; Wed, 27 Dec 2023 22:27:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1703744858; x=1704349658; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ezcMWpqhmHAMLrYn0+Q9MY7X5OW7VKM8sl5WwMShxTE=; b=JAw+/nS9zoAliofEWk5N8/OC2ihpkcUiCF++bhH/Kjt6JnKUwFIlHMMFUlAkh7nR7a 7oMBPC3hAi62BcbBV3CdJg82Sc2HGLsnJXcdqsmB0731LvyN84V6jnu69obFTkOxQDQS amgtKYBf0C4cFhauBqYvBLoKVuwtLKyIFS9lphgdEqDC8LezfKZkZFWIoGumK5LW/dzO jpFPiie+atJFOo4D6azUclCqI99rfHZe23QuW+HahFwRYqWqW9apWg3o9wqmMYuu/Bvu CS5YGnHCfLYkrn+ubOrIvxbDTVLk2ly+kimL7wtfk/G+fMzfMAQi5rMLL2Q7f/0W1s6y R4fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703744858; x=1704349658; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ezcMWpqhmHAMLrYn0+Q9MY7X5OW7VKM8sl5WwMShxTE=; b=J/XtsTqop59ezaMMIMJSBnkEkw59eHEudvIGEbJUSWtjbJTvuo3Z/DW14wLYEP+2DQ JBPxyAXk14C3JqcPmOKDaQQn6eyw9L0ZMoDUI5SiW577mWrw05kv5WxPKa10iBVuWfAn qoNL6ialEp77ScJnFVG9L56ZzQc4qigzPjeoHrh6YJwvtLylILCRpE5gBfOx4y4sv+rd KuWMNpyq8WZS/Wu7zuwRbBBf2o4vy7OBSVzlaUwKCFHKlQPpxAp4KKXIX4lv40NunA3n ijPduMvi6SFv0zbNfL6xvsyfNsRDAMNfmZk7i2mWrazuWEaVimwu8eLaIiVuYFB4CqDb TSxw== X-Gm-Message-State: AOJu0YyS5pxDq/WRubWay0ZG83dOBuncUY45/ko0B7A0GZ+dNQO5FlKt bKkAwiB2TqWT8qSrPcZH2vyrgOfM+4CQrQ== X-Received: by 2002:a05:6830:610e:b0:6dc:1ddd:b7ff with SMTP id ca14-20020a056830610e00b006dc1dddb7ffmr188180otb.49.1703744858464; Wed, 27 Dec 2023 22:27:38 -0800 (PST) Received: from ubuntu-haifeng.default.svc.cluster.local ([101.127.248.173]) by smtp.gmail.com with ESMTPSA id g5-20020aa78745000000b006d9af8c25easm7681381pfo.84.2023.12.27.22.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 22:27:38 -0800 (PST) From: Haifeng Xu To: roman.gushchin@linux.dev Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org, shakeelb@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Haifeng Xu Subject: [PATCH 1/2] mm: list_lru: disable memcg_aware when cgroup.memory is set to "nokmem" Date: Thu, 28 Dec 2023 06:27:14 +0000 Message-Id: <20231228062715.338672-1-haifeng.xu@shopee.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786505994598658234 X-GMAIL-MSGID: 1786505994598658234 Actually, when using a boot time kernel option "cgroup.memory=nokmem", all lru items are inserted to list_lru_node. But for those users who invoke list_lru_init_memcg() to initialize list_lru, list_lru_memcg_aware() returns true. And this brings unneeded operations related to memcg. To make things more convenient, let's disable memcg_aware when cgroup.memory is set to "nokmem". Signed-off-by: Haifeng Xu Acked-by: Roman Gushchin --- mm/list_lru.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/list_lru.c b/mm/list_lru.c index a05e5bef3b40..86f63c92fd88 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -566,6 +566,9 @@ int __list_lru_init(struct list_lru *lru, bool memcg_aware, lru->shrinker_id = shrinker->id; else lru->shrinker_id = -1; + + if (mem_cgroup_kmem_disabled()) + memcg_aware = false; #endif lru->node = kcalloc(nr_node_ids, sizeof(*lru->node), GFP_KERNEL); From patchwork Thu Dec 28 06:27:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haifeng Xu X-Patchwork-Id: 183645 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1834213dyb; Wed, 27 Dec 2023 22:28:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfHcBHiPP+cJBx7PJ5+r/m3SunMTc2AyNF6QL6VXEP8ivNz7KzJb7GOv+yGhOInY/mSbxC X-Received: by 2002:a17:902:ea02:b0:1d4:3af0:866a with SMTP id s2-20020a170902ea0200b001d43af0866amr9229986plg.21.1703744904301; Wed, 27 Dec 2023 22:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703744904; cv=none; d=google.com; s=arc-20160816; b=bOyJNxbnR8PN/YgTGEOpsmgGpldC7ZeBc9wRLnVdUOMrhCq9awf4vbHus9WUyb1P8a bn7BBdKFuOW53IzYEuuIjXZvddxCXBIcyoKrWROyN5aumN6ktmucDSJWoqwQgcDIuSF1 NCE+sOPs4eIaYpNqvDJGkpywwS8+8Thhi4jpID0fGrEn+9FN1EOz9IOUdUNIYD5SjVrF TD3Von2vI7G3L4RxmJtyLpE29cJlZIJf1DdMTtn0olYAfcqpUES5/FajfbGqBEsFcCow hKnMc+DBMKv5ZFE8fD9obbwVDckXN4MVRq1SzyiaCsQdPHyhGSeARp+6Z8MhtMNZg0rv k9GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Sxksy5E1CXPNQaU5KEcULgXjRO+AwfRR0MftjysBlZ4=; fh=pfOfK6fK5+onSwSyJBXnd63HJvzPImPyoGOtiqyyjLE=; b=keXADKDroINkz7GOZJUpcBzmdlaMva0Ju/aUBwMs2ElBlKQT+8huYP2S/EkR6BtFff mBxgLztIP48Wp12nQhjkI6ep3TdjxJsNql9hkJ+tyA6TblIU2DYOOdb8qsKp74wWzRCe FnMor4NiR4EBervOADn4VljqIaTS56VcIdyT27qAIl7cT1Nv5GhiYlb2XfxpxYZQn/6w 9npjzCZuAKbMunDZcwy2FbhpZ9b7YYKH1Nn3RmtCliyejldPa/lpGWzAH35B4gjvncXR n3VBNkXiU3+UdQygltfcZ9z3xvG0DGt0JpuzjzUPHK/k1Uoart5SWamQizuRAHkayjEQ ybOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shopee.com header.s=shopee.com header.b="RkYOYQ/X"; spf=pass (google.com: domain of linux-kernel+bounces-12458-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12458-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=shopee.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s2-20020a656902000000b005b92b048254si9995818pgq.201.2023.12.27.22.28.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 22:28:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12458-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@shopee.com header.s=shopee.com header.b="RkYOYQ/X"; spf=pass (google.com: domain of linux-kernel+bounces-12458-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12458-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=shopee.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 18E42282CD9 for ; Thu, 28 Dec 2023 06:28:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CC5E6D3F; Thu, 28 Dec 2023 06:27:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b="RkYOYQ/X" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 579895393 for ; Thu, 28 Dec 2023 06:27:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shopee.com Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-5c6839373f8so3614674a12.0 for ; Wed, 27 Dec 2023 22:27:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1703744862; x=1704349662; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Sxksy5E1CXPNQaU5KEcULgXjRO+AwfRR0MftjysBlZ4=; b=RkYOYQ/XFuJZzzuSorZBnV3UITFneEd0OlCsW/GA7Ht1u+xgqjaXMIHafH9NPxpAZ0 0mlO5dNftx/gBfkJQ3Qh+ej1MBhGAv5GPPYGFBucPEHvFMSFmM5NS6wvuVFlTABUw+L5 Kkqo7bwhNP2fAb25ZgigjaOybZEoN6+DiE4b7TX56NbXtUtTr2SgsWZpfwq8dyBxqP1x 5Dtxri5bLQcvvNo15YVOC7lsbeg1iV0j8f6T8BfiJY4BYeiVlVgl4fWiNSMjwMfnGLFs sOfjaLbAgTaMZ11dEaiNdBeex8ZYAr1+ZbuJsgZVYCFGfVTv23PU+e0CzL1MG0s10HKV M5KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703744862; x=1704349662; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Sxksy5E1CXPNQaU5KEcULgXjRO+AwfRR0MftjysBlZ4=; b=CnIXJlDgtkM1saI71fvOiA9rN10J1f1BuipgUm/SNkNlSZv/HqrfsIaCW/zsVPXT+P NjQoCcExvj/20mjcT0M/ll8yfvWCS8a/6SemZyfkFpLfLAQ4NAyKCyPn9sqOGUIJLUqc t1v/zu8wttLDDh/YX8AWHTJ9zpNNNjHhKLW8GiA5qnd9HBsirWbTuFH9zw/U3obSRsKN pzp0A3wUaAVOtkrG5ZiQs9t+o8sbPHGIub6efmksBjISJUM4cvxNTzVwwGZdYeyDwAwT A01ArijhfynxS6y+prpLPN9EBV4SBPShJTFO1Z3tYJz5d5gRPVBkYgIHTRaKyzOTAnVy nELA== X-Gm-Message-State: AOJu0YwhKUHXXJXEPqSyb8KeTCqq009Um7ESR5y4tZIQwwlRMvXq7sGA ZMQmVnn398wtMW112lCuFQRJiBkh++EfNQ== X-Received: by 2002:a05:6a20:7346:b0:196:2c18:fe7 with SMTP id v6-20020a056a20734600b001962c180fe7mr1993962pzc.14.1703744862596; Wed, 27 Dec 2023 22:27:42 -0800 (PST) Received: from ubuntu-haifeng.default.svc.cluster.local ([101.127.248.173]) by smtp.gmail.com with ESMTPSA id g5-20020aa78745000000b006d9af8c25easm7681381pfo.84.2023.12.27.22.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 22:27:42 -0800 (PST) From: Haifeng Xu To: roman.gushchin@linux.dev Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org, shakeelb@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Haifeng Xu Subject: [PATCH 2/2] mm: list_lru: remove unused macro list_lru_init_key() Date: Thu, 28 Dec 2023 06:27:15 +0000 Message-Id: <20231228062715.338672-2-haifeng.xu@shopee.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786506017164369655 X-GMAIL-MSGID: 1786506017164369655 list_lru_init_key() isn't used by anyone, remove it to clean up. Signed-off-by: Haifeng Xu Acked-by: Roman Gushchin --- include/linux/list_lru.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h index b35968ee9fb5..57a445a5001f 100644 --- a/include/linux/list_lru.h +++ b/include/linux/list_lru.h @@ -62,8 +62,6 @@ int __list_lru_init(struct list_lru *lru, bool memcg_aware, #define list_lru_init(lru) \ __list_lru_init((lru), false, NULL, NULL) -#define list_lru_init_key(lru, key) \ - __list_lru_init((lru), false, (key), NULL) #define list_lru_init_memcg(lru, shrinker) \ __list_lru_init((lru), true, NULL, shrinker)