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 BD0AFC433E3 for ; Mon, 24 Aug 2020 16:03:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95AF92072D for ; Mon, 24 Aug 2020 16:03:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DhR4iTc4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbgHXQD2 (ORCPT ); Mon, 24 Aug 2020 12:03:28 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:45432 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726727AbgHXQC6 (ORCPT ); Mon, 24 Aug 2020 12:02:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598284975; 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=DhR4iTc47y+ZBv2Yb0yNRGx26eVpZAbahIMo1FqqP+1ecPzgzFs/MSxB5P+m+doz4kk75H jbrK++sBKQtgLrlvTXKrkvmm7yOLfcEmAxOtRGyetmzgCjhPWDgBAaoDTCCN+b4WDC6dqL Za5fT+WODCbKQumsb6sY4ZjqcfyQdrk= 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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