From patchwork Fri Feb 26 09:17:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 12106191 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=-16.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 F1DF8C433E6 for ; Fri, 26 Feb 2021 09:17:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3406964EE7 for ; Fri, 26 Feb 2021 09:17:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3406964EE7 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AFE716B0072; Fri, 26 Feb 2021 04:17:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD2C78D0002; Fri, 26 Feb 2021 04:17:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C18F8D0001; Fri, 26 Feb 2021 04:17:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id 862476B0072 for ; Fri, 26 Feb 2021 04:17:39 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4CFAF183605FF for ; Fri, 26 Feb 2021 09:17:39 +0000 (UTC) X-FDA: 77859866238.15.B5F3BD3 Received: from mail-qt1-f202.google.com (mail-qt1-f202.google.com [209.85.160.202]) by imf22.hostedemail.com (Postfix) with ESMTP id 49CAAC0007CE for ; Fri, 26 Feb 2021 09:17:35 +0000 (UTC) Received: by mail-qt1-f202.google.com with SMTP id d10so6123907qtx.8 for ; Fri, 26 Feb 2021 01:17:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=0x/I6VizqDyhm0WRlAzYBf6vGqHgQIhvNWl/lQMoOjU=; b=ufifuNchyUu2Nt42yOFNtvE/0fxr6qejoIo4Dev4JvqNYsjyp0xq7qZdQrLXSib3Li SlXaXsyXqwvxynIi718qmiG/z2vXsv+d0yTBbaVvGpvzSXg70ChdMtwM2sJR5AYucgsF QBFvSAWneW8HKhkJBK0wYqaLwHkm0pwr4RTSg7IUnDogznC/HmPLCYeM4g0lb2Jx3jI+ pHoNnLMV0w3KiEjAQ0gj5pMP1TG8Hc0UqODqK2b4Oymszu7WiJWR/NvTvPnf7Dou+PSl M46fxIkgoMQjQbRTIDmyyQvXAnGgh891FKyfxRYZMoKfVV8EMNGllFaiX3SBpQcwF5dR qtXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=0x/I6VizqDyhm0WRlAzYBf6vGqHgQIhvNWl/lQMoOjU=; b=mC1O0f2NBVOMZgjk8NjZJk48/sIy8VDALjjuEUQB+TFX0KKGnibqpijyVV6z2qIpNR SDzvxI0xukhMajtKrP4iakZyH9rvSSKZZVZE/Gzd1J6sP1jGQujhFNhivvJX+ycnPbjc 4PLQ4xM3Rpt7qfIiXQzqLuUSBwjr2RjqQsnnegLqk6jgoT+GudGbOAHMx3zeR6Z82sZp Rf9KJtQLpupq2wNSZeqimsWA0t0a54XSDku0o22rlWYBW9BTqYMc6hryhg1Y2TxAubSo VXw1F2HzDcrwttAaCbU7uSeHdKSg5ryiVb5CNvyQpF8H0nhnv+1WMnthpzqwG4iVeTVc 2GoQ== X-Gm-Message-State: AOAM532dUqwrofATlnEcY2pinwdDqevypL0yKaMQl/MOSFwLLGo7DOH/ AADxH/05wpE2wc69U31b2hK8A4GCuMA= X-Google-Smtp-Source: ABdhPJw/aX/0da6jr3fSWHl1QzaFZ7UomaCtvoWaPyk2ZmV0Zmb1C1s8a8/tVeafRVV6AkPSlq9+KbqfxQ4= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:69b6:2618:c96a:ceba]) (user=yuzhao job=sendgmr) by 2002:ad4:50c7:: with SMTP id e7mr1843885qvq.58.1614331058054; Fri, 26 Feb 2021 01:17:38 -0800 (PST) Date: Fri, 26 Feb 2021 02:17:16 -0700 In-Reply-To: <20210226091718.2927291-1-yuzhao@google.com> Message-Id: <20210226091718.2927291-2-yuzhao@google.com> Mime-Version: 1.0 References: <20210224084807.2179942-1-yuzhao@google.com> <20210226091718.2927291-1-yuzhao@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH v2 1/3] mm: bypass compound_head() for PF_NO_TAIL when enforce=1 From: Yu Zhao To: akpm@linux-foundation.org, alex.shi@linux.alibaba.com, vbabka@suse.cz, willy@infradead.org Cc: guro@fb.com, hannes@cmpxchg.org, hughd@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@kernel.org, vdavydov.dev@gmail.com, Yu Zhao X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 49CAAC0007CE X-Stat-Signature: 7gqrk6rw7zwgw78ryt181it8r4r651kq Received-SPF: none (flex--yuzhao.bounces.google.com>: No applicable sender policy available) receiver=imf22; identity=mailfrom; envelope-from="<3srw4YAYKCBcLHM4xB3BB381.zB985AHK-997Ixz7.BE3@flex--yuzhao.bounces.google.com>"; helo=mail-qt1-f202.google.com; client-ip=209.85.160.202 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614331055-848099 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: When testing page flags with PF_NO_TAIL (enforce=0), tail pages are legit and they are converted by compound_head(). When modifying page flags (enforce=1), tail pages are not legit and they either trigger VM_BUG_ON_PGFLAGS() or are "corrected" by compound_head(). There is no evidence such "correction" is beneficial in terms of preventing a buggy kernel from crashing. But there is clear evidence it's detrimental to the size of vmlinux because compound_head() is redundantly inlined for all modifications of small and head page flags using PF_NO_TAIL. This patch makes PF_NO_TAIL skip compound_head() when modifying page flags. There won't be any behavior change unless a piece of buggy code tries to modify tail page flags using PF_NO_TAIL. Such code won't be "corrected", if VM_BUG_ON_PGFLAGS() isn't there to catch it. Again, there is no evidence such "correction" is beneficial. bloat-o-meter result: add/remove: 0/0 grow/shrink: 4/62 up/down: 309/-2851 (-2542) Signed-off-by: Yu Zhao --- include/linux/page-flags.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index db914477057b..1995208a3763 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -248,7 +248,7 @@ static inline void page_init_poison(struct page *page, size_t size) PF_POISONED_CHECK(page); }) #define PF_NO_TAIL(page, enforce) ({ \ VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \ - PF_POISONED_CHECK(compound_head(page)); }) + PF_POISONED_CHECK((enforce) ? (page) : compound_head(page)); }) #define PF_NO_COMPOUND(page, enforce) ({ \ VM_BUG_ON_PGFLAGS(enforce && PageCompound(page), page); \ PF_POISONED_CHECK(page); }) From patchwork Fri Feb 26 09:17:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 12106193 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=-16.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 D9D6AC433E0 for ; Fri, 26 Feb 2021 09:17:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 32A27601FC for ; Fri, 26 Feb 2021 09:17:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32A27601FC Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 18C526B0073; Fri, 26 Feb 2021 04:17:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0ECA78D0002; Fri, 26 Feb 2021 04:17:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EEF6F8D0001; Fri, 26 Feb 2021 04:17:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id D80D36B0073 for ; Fri, 26 Feb 2021 04:17:40 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id AED35A741 for ; Fri, 26 Feb 2021 09:17:40 +0000 (UTC) X-FDA: 77859866280.01.D24B983 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf08.hostedemail.com (Postfix) with ESMTP id CB4E580192D8 for ; Fri, 26 Feb 2021 09:17:27 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id v62so9420639ybb.15 for ; Fri, 26 Feb 2021 01:17:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=k0AsilW2lYipSpVRHZF9m6q/kGFfsp0ZK/tsphAGUXA=; b=UHEC7ePpDsJxvd5Z+OdWIwRzJX+EcAcdBJEBOYglWMs7rB+gp9uZxDQaNXeYa+ofaJ SiEpldqigfsRGuA4QBVnhtIfqzHB7PsKkXWCayrA0xA2MQHGNejP4oKuhd6tH0GSmKAb 98+hYxQYCRGa7ezb8EDKcXVFiGCnrPzid2kg4uTLKqeY2y4RIsgBh2mgjCzo8pWDL84l dbw0PXJYZIZbc+KwexI+I7CaM3cH5eWaTIOG95eknluTAh5bOxasbNCVkWjhKuEWZMOA BahRgoFguRSEXrdZAODV6x981mT424sbq7WH6yf0yHp4KYmnAw5myb0dELfiut5iPDa8 m6/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=k0AsilW2lYipSpVRHZF9m6q/kGFfsp0ZK/tsphAGUXA=; b=niu6ITYv3nzpgQQKJLuQH37IM94JyREiTlHEKzIeGkSjvD23TcgegmMA86KgEHlUT+ WldXb9bnLaFq78oux+VR5pWB9LLL06gfKTXuUwrj75u+Bj83f08FQuFDx3rU8iBDSeAm ggdcVx4pfifohRTHuAe7LAluQfzR6MzjOD/UET/L+YHNZ3n7SNlNMwuSN6A6I2uyyFwR ibyB5EAKJ7gNg0Txjti4E/elVOpiuttR81iJFLnMF1iW8tNQjKDMqGUDKlRVYQ9abDe4 sNC4xkhvG7pBf3t4N5zcgqPD/jFz2kRrcdbpdG8xuUYaVoKBnmRe75rD0sglj2SD2tk9 Fk1A== X-Gm-Message-State: AOAM5316qGqQ5jjTmBNYJTFrbwETiPn9TPr/emLspIBUdKTeNe+wz956 jBGDm+BY9Qw2rRfKY5bOER6rFIGrqEc= X-Google-Smtp-Source: ABdhPJwIpDGfxBRdjyRoue8vq2zd8/aPXQONGuLd0v8LLbixUC5GkHVl4LonYYZAHNYpAdHhTddLH3b5xfA= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:69b6:2618:c96a:ceba]) (user=yuzhao job=sendgmr) by 2002:a5b:2cb:: with SMTP id h11mr3280115ybp.428.1614331059498; Fri, 26 Feb 2021 01:17:39 -0800 (PST) Date: Fri, 26 Feb 2021 02:17:17 -0700 In-Reply-To: <20210226091718.2927291-1-yuzhao@google.com> Message-Id: <20210226091718.2927291-3-yuzhao@google.com> Mime-Version: 1.0 References: <20210224084807.2179942-1-yuzhao@google.com> <20210226091718.2927291-1-yuzhao@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH v2 2/3] mm: use PF_NO_TAIL for PG_lru From: Yu Zhao To: akpm@linux-foundation.org, alex.shi@linux.alibaba.com, vbabka@suse.cz, willy@infradead.org Cc: guro@fb.com, hannes@cmpxchg.org, hughd@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@kernel.org, vdavydov.dev@gmail.com, Yu Zhao X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: CB4E580192D8 X-Stat-Signature: 8x835b75hb345k3ss1i7t3985g1c4rbc Received-SPF: none (flex--yuzhao.bounces.google.com>: No applicable sender policy available) receiver=imf08; identity=mailfrom; envelope-from="<3s7w4YAYKCBgMIN5yC4CC492.0CA96BIL-AA8Jy08.CF4@flex--yuzhao.bounces.google.com>"; helo=mail-yb1-f202.google.com; client-ip=209.85.219.202 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614331047-344153 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: Trying to set or clear PG_lru on tail pages has been considered buggy. Enforce this rule by changing the policy for PG_lru from PF_HEAD to PF_NO_TAIL. This means setting or clearing PG_lru on tail pages won't be "corrected" by compound_page(). Such "correction" isn't helpful -- even if a piece of buggy code has gotten away with compound_page(tail)->flags, it will run into trouble with lru list addition and deletion because they use tail->lru rather than compound_page(tail)->lru. bloat-o-meter result: add/remove: 0/0 grow/shrink: 0/11 up/down: 0/-535 (-535) Signed-off-by: Yu Zhao --- include/linux/page-flags.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 1995208a3763..c9626e54df8d 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -333,8 +333,8 @@ PAGEFLAG(Referenced, referenced, PF_HEAD) __SETPAGEFLAG(Referenced, referenced, PF_HEAD) PAGEFLAG(Dirty, dirty, PF_HEAD) TESTSCFLAG(Dirty, dirty, PF_HEAD) __CLEARPAGEFLAG(Dirty, dirty, PF_HEAD) -PAGEFLAG(LRU, lru, PF_HEAD) __CLEARPAGEFLAG(LRU, lru, PF_HEAD) - TESTCLEARFLAG(LRU, lru, PF_HEAD) +PAGEFLAG(LRU, lru, PF_NO_TAIL) __CLEARPAGEFLAG(LRU, lru, PF_NO_TAIL) + TESTCLEARFLAG(LRU, lru, PF_NO_TAIL) PAGEFLAG(Active, active, PF_HEAD) __CLEARPAGEFLAG(Active, active, PF_HEAD) TESTCLEARFLAG(Active, active, PF_HEAD) PAGEFLAG(Workingset, workingset, PF_HEAD) From patchwork Fri Feb 26 09:17:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 12106195 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=-16.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 E67AFC433DB for ; Fri, 26 Feb 2021 09:17:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6521D64EE7 for ; Fri, 26 Feb 2021 09:17:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6521D64EE7 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 63F0C6B0074; Fri, 26 Feb 2021 04:17:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 619258D0002; Fri, 26 Feb 2021 04:17:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 494108D0001; Fri, 26 Feb 2021 04:17:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0162.hostedemail.com [216.40.44.162]) by kanga.kvack.org (Postfix) with ESMTP id 2B9646B0074 for ; Fri, 26 Feb 2021 04:17:42 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DC40B18343F7E for ; Fri, 26 Feb 2021 09:17:41 +0000 (UTC) X-FDA: 77859866322.08.CE7A423 Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by imf22.hostedemail.com (Postfix) with ESMTP id DF1FCC0007D2 for ; Fri, 26 Feb 2021 09:17:37 +0000 (UTC) Received: by mail-qk1-f202.google.com with SMTP id t6so2672206qkt.14 for ; Fri, 26 Feb 2021 01:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=Sbwg5mnD28MfpC+5A1wM48SOZxACByUsBU0/u8gNTKY=; b=pDKOOjv7DnHHQqrg/o+zEsKkWF6x5gJ8Fur6sxRl9VJeF+L2t+3lXAtN4UD3QfSEGf gNuU11Wvw8rCxdt+EtvkzV0n17p5vz/d2YcjCL/AJ+Wq2obyFyYTXnOQmxJoPP2Vfqjg egIrc2c6XpfhqnxV640YmCd8zBD/336iPLy2rZ/sgobFxh0J2C9KF4lJFihbfy5U41Z0 KXTFcssDgfbdmsGx08n3uKiG3a+GYRPOmiGO7rCb/QJ9JtlMgmnW4mH4b7olvP1gnS3e KZA231HlJ5VE7LiFn+VXX19WqPl501ql30DaMJFESUtP7G1mUtQPxdck5md0v29w6DPM 5Qhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Sbwg5mnD28MfpC+5A1wM48SOZxACByUsBU0/u8gNTKY=; b=lPLxGR3P7Y2Pv2LgQYOU1HpLEphBch4ga55BjgaIDpU1ZGevOBGycOsufZy7CCuZjw OXngZM3wmUPHKhCUfBg2rsMAKaqXqPub5E/pZxOjcpx/mQfeyetZbRENssiKWa5+f/ZU uHQeLxJmBiSa7hYUBOUr/DcZBJ0nupobXbokPtMNE2rcuYg8xCvW+vBshISiuY73yqy1 m35h4nckS7L1dsWytXEd/PH7gf45AP8rwiv5Xd0CmrtY310sBoS3DKur3rFQF2xhkoGV /SVLBY32BN4e7X2erkxLxU3SgH3U2FlP9cbYtASjEy4aoiYr51VtxU5DIwYAApViPYRz 1+8Q== X-Gm-Message-State: AOAM531Mik3gD87bVuTTZSUYcm0OArk+pEu6fyUYAgVIY94V3JuFJoPw FvAe54anphVUQjQsCBISN7V8y245R88= X-Google-Smtp-Source: ABdhPJw49NwW1osDcsWfZjZWCmhBnG2VmrWEsp3yjpjWhKXeQaLf57JEP91v5nodzzC+al8WBoFwA4ENe74= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:69b6:2618:c96a:ceba]) (user=yuzhao job=sendgmr) by 2002:a0c:b998:: with SMTP id v24mr1673365qvf.4.1614331060711; Fri, 26 Feb 2021 01:17:40 -0800 (PST) Date: Fri, 26 Feb 2021 02:17:18 -0700 In-Reply-To: <20210226091718.2927291-1-yuzhao@google.com> Message-Id: <20210226091718.2927291-4-yuzhao@google.com> Mime-Version: 1.0 References: <20210224084807.2179942-1-yuzhao@google.com> <20210226091718.2927291-1-yuzhao@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH v2 3/3] mm: use PF_ONLY_HEAD for PG_active and PG_unevictable From: Yu Zhao To: akpm@linux-foundation.org, alex.shi@linux.alibaba.com, vbabka@suse.cz, willy@infradead.org Cc: guro@fb.com, hannes@cmpxchg.org, hughd@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@kernel.org, vdavydov.dev@gmail.com, Yu Zhao X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: DF1FCC0007D2 X-Stat-Signature: hqzhfrquxqtmn3aairuryrjnpiuysn76 Received-SPF: none (flex--yuzhao.bounces.google.com>: No applicable sender policy available) receiver=imf22; identity=mailfrom; envelope-from="<3tLw4YAYKCBkNJO6zD5DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--yuzhao.bounces.google.com>"; helo=mail-qk1-f202.google.com; client-ip=209.85.222.202 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614331057-743996 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: All places but one test, set or clear PG_active and PG_unevictable on small or head pages. Use compound_head() explicitly for that singleton so the rest can rid of redundant compound_head(). bloat-o-meter result: add/remove: 0/0 grow/shrink: 3/38 up/down: 388/-4270 (-3882) Signed-off-by: Yu Zhao --- fs/proc/task_mmu.c | 3 ++- include/linux/page-flags.h | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 3cec6fbef725..c866c363bb41 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1712,6 +1712,7 @@ static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty, unsigned long nr_pages) { int count = page_mapcount(page); + struct page *head = compound_head(page); md->pages += nr_pages; if (pte_dirty || PageDirty(page)) @@ -1720,7 +1721,7 @@ static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty, if (PageSwapCache(page)) md->swapcache += nr_pages; - if (PageActive(page) || PageUnevictable(page)) + if (PageActive(head) || PageUnevictable(head)) md->active += nr_pages; if (PageWriteback(page)) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index c9626e54df8d..b7fe855a6ee9 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -335,8 +335,8 @@ PAGEFLAG(Dirty, dirty, PF_HEAD) TESTSCFLAG(Dirty, dirty, PF_HEAD) __CLEARPAGEFLAG(Dirty, dirty, PF_HEAD) PAGEFLAG(LRU, lru, PF_NO_TAIL) __CLEARPAGEFLAG(LRU, lru, PF_NO_TAIL) TESTCLEARFLAG(LRU, lru, PF_NO_TAIL) -PAGEFLAG(Active, active, PF_HEAD) __CLEARPAGEFLAG(Active, active, PF_HEAD) - TESTCLEARFLAG(Active, active, PF_HEAD) +PAGEFLAG(Active, active, PF_ONLY_HEAD) __CLEARPAGEFLAG(Active, active, PF_ONLY_HEAD) + TESTCLEARFLAG(Active, active, PF_ONLY_HEAD) PAGEFLAG(Workingset, workingset, PF_HEAD) TESTCLEARFLAG(Workingset, workingset, PF_HEAD) __PAGEFLAG(Slab, slab, PF_NO_TAIL) @@ -407,9 +407,9 @@ CLEARPAGEFLAG(SwapCache, swapcache, PF_NO_TAIL) PAGEFLAG_FALSE(SwapCache) #endif -PAGEFLAG(Unevictable, unevictable, PF_HEAD) - __CLEARPAGEFLAG(Unevictable, unevictable, PF_HEAD) - TESTCLEARFLAG(Unevictable, unevictable, PF_HEAD) +PAGEFLAG(Unevictable, unevictable, PF_ONLY_HEAD) + __CLEARPAGEFLAG(Unevictable, unevictable, PF_ONLY_HEAD) + TESTCLEARFLAG(Unevictable, unevictable, PF_ONLY_HEAD) #ifdef CONFIG_MMU PAGEFLAG(Mlocked, mlocked, PF_NO_TAIL)