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=-12.3 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,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 CB20BC433ED for ; Thu, 15 Apr 2021 16:35:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3FAD5611AD for ; Thu, 15 Apr 2021 16:35:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3FAD5611AD 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 C35EA6B0036; Thu, 15 Apr 2021 12:35:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BEA0C6B006C; Thu, 15 Apr 2021 12:35:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A38B96B0070; Thu, 15 Apr 2021 12:35:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id 812D56B0036 for ; Thu, 15 Apr 2021 12:35:51 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 370071807867A for ; Thu, 15 Apr 2021 16:35:51 +0000 (UTC) X-FDA: 78035152902.31.F2E3CAC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id B96F0E00010E for ; Thu, 15 Apr 2021 16:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618504550; 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=s47wUvhDxo7f8LaX+UuV/f8OqzaAqCVXK0vtBt6gLnc=; b=FYmibwOvsQ/3bq1uvCQrILUCuFotTsoUHM7QDc3LeHXDG5PFG8618dMMyPnnW78N1XUO6j OLBERX4I/YSBS2o3F8ZojIWrhRDhIqK5/18pAOH6tGXfF9iEPK+4zJ7yKABbSrig6hDB5C fSK9yQIAoRznQjm95c2Yxjol/4gkDUU= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-lWSIO-gGOxKHq7KdfDzVxA-1; Thu, 15 Apr 2021 12:35:48 -0400 X-MC-Unique: lWSIO-gGOxKHq7KdfDzVxA-1 Received: by mail-qt1-f200.google.com with SMTP id n15-20020ac8674f0000b02901b3da8d8dccso4286344qtp.21 for ; Thu, 15 Apr 2021 09:35:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=s47wUvhDxo7f8LaX+UuV/f8OqzaAqCVXK0vtBt6gLnc=; b=ATw52NNH7BjknYZ0lEv+1D3Ii09JXb3QR/9ITXCubyiDOb2q6/qSIJj4ggXeDCQRv7 nFZik686apV3zO3tWDHnxQAkx1g629FnXTRFe6wRjCUdUjaMkRzYhJ1uhocaTOAB3stB A+NH2DlVJlcLcqTr3gzJP9IRLBZjclS1Yz1rR0JHN/nIoXwBYVgLSRFovlSAEEN3pszc TF11N/IMyxlmbSbo+p3h23QXsvMBFfdj4o3at5EkgdJW5GBrEGFwRRUuJWZK1dDsua7T sohCTaf/s310FRlb8qZriBkJl8/y5Ym5rK6uOOPORDkXYspLcPaTauEEFjri8jW3m8Kq pm7Q== X-Gm-Message-State: AOAM532vKM3kN5RJQe22S9S/egGcVVbUuJKxttG4706TsXIZOdRWUylo pr0tQ++afBgmv9/kh7zObkEqUT+QE8qEv3lnLD8thHg0HvGkIEl1Ak/Dg0S/UBIVBevQWo+Bry7 FzoNDd67wgh0= X-Received: by 2002:a05:622a:14c6:: with SMTP id u6mr3732877qtx.125.1618504547882; Thu, 15 Apr 2021 09:35:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdrAITzN7+b2b1F20V9MktKhAkmPaXFgdVujfeKgC7dKMBGFp5V/bRqqBWQ3QhezwWOXSwBg== X-Received: by 2002:a05:622a:14c6:: with SMTP id u6mr3732852qtx.125.1618504547668; Thu, 15 Apr 2021 09:35:47 -0700 (PDT) Received: from llong.remote.csb ([2601:191:8500:76c0::cdbc]) by smtp.gmail.com with ESMTPSA id 26sm2171153qtd.73.2021.04.15.09.35.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Apr 2021 09:35:47 -0700 (PDT) From: Waiman Long X-Google-Original-From: Waiman Long Subject: Re: [PATCH v3 2/5] mm/memcg: Introduce obj_cgroup_uncharge_mod_state() To: Johannes Weiner Cc: Michal Hocko , Vladimir Davydov , Andrew Morton , Tejun Heo , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt , Muchun Song , Alex Shi , Chris Down , Yafang Shao , Wei Yang , Masayoshi Mizuma , Xing Zhengjun References: <20210414012027.5352-1-longman@redhat.com> <20210414012027.5352-3-longman@redhat.com> Message-ID: <1c85e8f6-e8b9-33e1-e29b-81fbadff959f@redhat.com> Date: Thu, 15 Apr 2021 12:35:45 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=llong@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Rspamd-Queue-Id: B96F0E00010E X-Stat-Signature: hegpfgg36et9iqjkqffrt8gbjn9azc99 X-Rspamd-Server: rspam02 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf21; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618504548-312527 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 4/15/21 12:30 PM, Johannes Weiner wrote: > On Tue, Apr 13, 2021 at 09:20:24PM -0400, Waiman Long wrote: >> In memcg_slab_free_hook()/pcpu_memcg_free_hook(), obj_cgroup_uncharge() >> is followed by mod_objcg_state()/mod_memcg_state(). Each of these >> function call goes through a separate irq_save/irq_restore cycle. That >> is inefficient. Introduce a new function obj_cgroup_uncharge_mod_state() >> that combines them with a single irq_save/irq_restore cycle. >> >> @@ -3292,6 +3296,25 @@ void obj_cgroup_uncharge(struct obj_cgroup *objcg, size_t size) >> refill_obj_stock(objcg, size); >> } >> >> +void obj_cgroup_uncharge_mod_state(struct obj_cgroup *objcg, size_t size, >> + struct pglist_data *pgdat, int idx) > The optimization makes sense. > > But please don't combine independent operations like this into a > single function. It makes for an unclear parameter list, it's a pain > in the behind to change the constituent operations later on, and it > has a habit of attracting more random bools over time. E.g. what if > the caller already has irqs disabled? What if it KNOWS that irqs are > enabled and it could use local_irq_disable() instead of save? > > Just provide an __obj_cgroup_uncharge() that assumes irqs are > disabled, combine with the existing __mod_memcg_lruvec_state(), and > bubble the irq handling up to those callsites which know better. > That will also work. However, the reason I did that was because of patch 5 in the series. I could put the get_obj_stock() and put_obj_stock() code in slab.h and allowed them to be used directly in various places, but hiding in one function is easier. Anyway, I can change the patch if you think that is the right way. Cheers, Longman