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 X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 E8382C433E4 for ; Mon, 24 Aug 2020 16:03:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AC1C92072D for ; Mon, 24 Aug 2020 16:03:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gJVgF0Wf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC1C92072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 191746B0008; Mon, 24 Aug 2020 12:03:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 11B786B000A; Mon, 24 Aug 2020 12:03:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 009966B000C; Mon, 24 Aug 2020 12:03:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0039.hostedemail.com [216.40.44.39]) by kanga.kvack.org (Postfix) with ESMTP id D8C876B0008 for ; Mon, 24 Aug 2020 12:03:14 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 596981F1B for ; Mon, 24 Aug 2020 16:03:14 +0000 (UTC) X-FDA: 77185931508.08.twist35_0a1574f27054 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 07CF01819E656 for ; Mon, 24 Aug 2020 16:03:04 +0000 (UTC) X-HE-Tag: twist35_0a1574f27054 X-Filterd-Recvd-Size: 4644 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Mon, 24 Aug 2020 16:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598284976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GOOvGMjNbf5XtLNCKd9ysNRuyAgV0fQgbTvlhMQq8xI=; b=gJVgF0Wfp/p5g8Cv3FTkIig8lpzIq2ogwl9BRE3+x4MAYWNGph2fh9F0eNBZfxAVQ36r0z wMYMPcx97q7AqYoWqdGseQrq/Ic00dc5mGfWTqZwmqsqI+c1zhny+SdtkIG14UK1nOdm4c qX6Tk8KKYWS937drlOLYiZ9B8Ikhubg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-465-FWvG5sP1NauODAXLjclCsQ-1; Mon, 24 Aug 2020 12:02:52 -0400 X-MC-Unique: FWvG5sP1NauODAXLjclCsQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2DC710ABDA5; Mon, 24 Aug 2020 16:02:49 +0000 (UTC) Received: from llong.remote.csb (ovpn-112-212.rdu2.redhat.com [10.10.112.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94F411002382; Mon, 24 Aug 2020 16:02:48 +0000 (UTC) Subject: Re: [PATCH 3/3] mm/memcg: Unify swap and memsw page counters To: Shakeel Butt Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Tejun Heo , LKML , Cgroups , Linux MM , Chris Down , Roman Gushchin , Yafang Shao References: <20200820130350.3211-1-longman@redhat.com> <20200820130350.3211-4-longman@redhat.com> From: Waiman Long Organization: Red Hat Message-ID: <18d02675-0c2a-bfc3-6953-42dcd10396b1@redhat.com> Date: Mon, 24 Aug 2020 12:02:48 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Rspamd-Queue-Id: 07CF01819E656 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 8/20/20 11:46 AM, Shakeel Butt wrote: > On Thu, Aug 20, 2020 at 6:04 AM Waiman Long wrote: >> The swap page counter is v2 only while memsw is v1 only. As v1 and v2 >> controllers cannot be active at the same time, there is no point to keep >> both swap and memsw page counters in mem_cgroup. The previous patch has >> made sure that memsw page counter is updated and accessed only when in >> v1 code paths. So it is now safe to alias the v1 memsw page counter to v2 >> swap page counter. This saves 14 long's in the size of mem_cgroup. This >> is a saving of 112 bytes for 64-bit archs. >> >> Signed-off-by: Waiman Long >> --- >> include/linux/memcontrol.h | 3 +-- >> mm/memcontrol.c | 8 +++++--- >> 2 files changed, 6 insertions(+), 5 deletions(-) >> >> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h >> index d0b036123c6a..d2a819d7db70 100644 >> --- a/include/linux/memcontrol.h >> +++ b/include/linux/memcontrol.h >> @@ -216,10 +216,9 @@ struct mem_cgroup { >> >> /* Accounted resources */ >> struct page_counter memory; >> - struct page_counter swap; >> + struct page_counter swap; /* memsw (memory+swap) for v1 */ >> >> /* Legacy consumer-oriented counters */ >> - struct page_counter memsw; >> struct page_counter kmem; >> struct page_counter tcpmem; >> >> diff --git a/mm/memcontrol.c b/mm/memcontrol.c >> index d219dca5239f..04c3794cdc98 100644 >> --- a/mm/memcontrol.c >> +++ b/mm/memcontrol.c >> @@ -68,6 +68,11 @@ >> >> #include >> >> +/* >> + * The v1 memsw page counter is aliased to the v2 swap page counter. >> + */ >> +#define memsw swap >> + > Personally I would prefer a union instead of #define. Yes, that is also what I am thinking about in the v2. Cheers, Longman