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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 CC8B7C47423 for ; Thu, 1 Oct 2020 19:01:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1FD972072E for ; Thu, 1 Oct 2020 19:01:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="ZC/sVh4M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FD972072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 892E06B005D; Thu, 1 Oct 2020 15:01:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 81CD56B0062; Thu, 1 Oct 2020 15:01:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E4E66B0068; Thu, 1 Oct 2020 15:01:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id 40A616B005D for ; Thu, 1 Oct 2020 15:01:34 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BEF6A362D for ; Thu, 1 Oct 2020 19:01:33 +0000 (UTC) X-FDA: 77324275266.25.rat42_4c060c52719d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 8AB0C1804E3A1 for ; Thu, 1 Oct 2020 19:01:33 +0000 (UTC) X-HE-Tag: rat42_4c060c52719d X-Filterd-Recvd-Size: 4870 Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Thu, 1 Oct 2020 19:01:32 +0000 (UTC) Received: by mail-qt1-f195.google.com with SMTP id c18so5574429qtw.5 for ; Thu, 01 Oct 2020 12:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=FA4b+JjxXDupd9SJaACVBkhyBnQSOUKDxz41oObhr2A=; b=ZC/sVh4MTmTpVP1kvhpWmIrWSWjSSBwEAJG9XlrOOb0NRz6k5LT2SNHthNb89UlcUh QqeXxS/u0piR9OSBGSFFjFcDckshdJTn1RncXI921BqZsUrRoH3s9uZxCjhSKQq2Fv3C jI5soOPJVkA3qey9iJ55SDXHdhq1h8HvBEl59kZ0BiG/YOpJlQ3SCvrHXYmcRJfMBFZv RM7bo9q59YsNKJAwsHY+ls6tI1A0aGzX6yI+eRUyeMG9z91clLoQv9mSVUKcN8f7qWik kK85g8AsYz9XqLOOFXLpeovR7J3qvV5gbo0kQPnXX5xNKEI7eezE4w+IVCgf+5rrDJov LVLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FA4b+JjxXDupd9SJaACVBkhyBnQSOUKDxz41oObhr2A=; b=Wb2O0orQGfoFh2yndTW24WDpXGG5/0vkJ2+TXee82apt4dk3e7Zsg/maDOmMJv1cMu atXtzGqeSE+hucO+XvNa6klX/DoLQeqT7C8FWkBUhyydrVc1zsQUYg37DRkB3ePuUN1a G2RK9QsfB7/ifj1ZuGFj3MeuZNSJbGGuqSM+5ZjpA292x5Dc4auS+OoURw2oGaucfnbO nK3J9l8Rx62E51Rf8sn8ecE7kXEL/o7D5GHT7WzzXVVVlIymqv/UIL9EeoR9MpWI3Al+ w8Mui09mZnDdHMNTkJ0oWbP7/cYMNnLm7m/TNFwcDWWjEtDqVuILiljPCOBfommTghgx QlXg== X-Gm-Message-State: AOAM530yQr8nXABWgaVhXlXEM0fmYG9RBHuLqwA2ovKQhrWjY0F7/0fk ElMOB52myWgRWtyCE3cdqst/ig== X-Google-Smtp-Source: ABdhPJzTEnBVYikmvH85woAsYBoLBjCp854qzeNnPxR3BcmIiM34MKzPsFfbojHoXJFeabAQLwLIMA== X-Received: by 2002:ac8:36ca:: with SMTP id b10mr2720461qtc.135.1601578892005; Thu, 01 Oct 2020 12:01:32 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:4e22]) by smtp.gmail.com with ESMTPSA id f189sm6932506qkd.20.2020.10.01.12.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 12:01:31 -0700 (PDT) Date: Thu, 1 Oct 2020 14:59:50 -0400 From: Johannes Weiner To: Roman Gushchin Cc: Andrew Morton , Shakeel Butt , Michal Hocko , linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel-team@fb.com Subject: Re: [PATCH v4 1/4] mm: memcontrol: use helpers to access page's memcg data Message-ID: <20201001185950.GB500308@cmpxchg.org> References: <20201001002710.748166-1-guro@fb.com> <20201001002710.748166-2-guro@fb.com> <20201001134638.GE469663@cmpxchg.org> <20201001182739.GA2706729@carbon.DHCP.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201001182739.GA2706729@carbon.DHCP.thefacebook.com> 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 Thu, Oct 01, 2020 at 11:27:39AM -0700, Roman Gushchin wrote: > On Thu, Oct 01, 2020 at 09:46:38AM -0400, Johannes Weiner wrote: > > On Wed, Sep 30, 2020 at 05:27:07PM -0700, Roman Gushchin wrote: > > > +/* > > > + * set_page_memcg - associate a page with a memory cgroup > > > + * @page: a pointer to the page struct > > > + * @memcg: a pointer to the memory cgroup > > > + * > > > + * Associates a page with a memory cgroup. > > > + */ > > > +static inline void set_page_memcg(struct page *page, struct mem_cgroup *memcg) > > > +{ > > > + VM_BUG_ON_PAGE(PageSlab(page), page); > > > + > > > + /* > > > + * Please, refer to page_memcg()'s description for the page and memcg > > > + * binding stability requirements. > > > + */ > > > + page->memcg_data = (unsigned long)memcg; > > > +} > > > > Please delete and inline this as per previous feedback, thanks. > > Why it's better? > It's ok for set_page_memcg(), but obviously worse for set_page_objcgs(): > it was nice to have all bit magic in one place, in few helper functions. > And now it spills into several places. What's the win? set_page_objcgs() is a worthwhile abstraction because it includes the synchronization primitives that make it safe to use wrt page_objcgs(). They encapsulate the cmpxchg and the READ_ONCE(). set_page_memcg() doesn't do any synchronization and relies fully on the contextual locking. The name implies that it includes things to make it safe wrt page_memcg(), which isn't true at all. It's a long and misleading name for '='. Btw, I really don't mind having this discussion, but please don't send revisions that silently ignore feedback you don't agree with. Thanks