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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 64692C433E0 for ; Sun, 14 Mar 2021 07:45:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CDDB564EB5 for ; Sun, 14 Mar 2021 07:45:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDDB564EB5 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 1AC616B0006; Sun, 14 Mar 2021 03:45:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 15DBC6B006E; Sun, 14 Mar 2021 03:45:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F18646B0070; Sun, 14 Mar 2021 03:45:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id D1ECE6B0006 for ; Sun, 14 Mar 2021 03:45:23 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 77AC4180220B0 for ; Sun, 14 Mar 2021 07:45:23 +0000 (UTC) X-FDA: 77917694526.01.12EAEEB Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) by imf19.hostedemail.com (Postfix) with ESMTP id 1FD7690009EA for ; Sun, 14 Mar 2021 07:45:22 +0000 (UTC) Received: by mail-io1-f50.google.com with SMTP id y20so11898144iot.4 for ; Sat, 13 Mar 2021 23:45:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=c2Df9KqMXmJAPX/BGJjQIjMHZK30Fyv7x3AyjGi8hZg=; b=mX5bmAeZvHLcUaOx8cqeBs2Jfh2QMjAnwdBhGoR82xhGZqp+5ORQGPJpkrk6e6LyMi NdJmkpQ4SAnriWfG69eGwkd0CP9u9c9WAEJCdOU/oXuirVtdqc44SEGsJkED+AOdQ/j6 axFqnDaOHIxBepJ5qp+iM3QPrFeKLxtNv0nM9fyIlXQMqb5iUcS1opNBRuQXTBEuvGc1 7/vUz5XzT27O9fAd3n9cSDtenBH5UOsFau2X5bt9yuQelyd0L6NbN8MYyPm+wRS6nqz1 MCEBLCaq7YIuE1Xcy2eCtGVyrMmVzj0R6H+ogVzDwpy3XmArkrYqm6wWUrUasl6LqB7o rnwA== 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=c2Df9KqMXmJAPX/BGJjQIjMHZK30Fyv7x3AyjGi8hZg=; b=bRSinB38Zjzvtlzjp//Nyg4Nhyd+8s3X9HEhVMw96p7chzWkwbUFtjT0LK4M0DuRsk 932Z9k94upEZHzSYzwJoRO5cm4zfbqRlwSi7riyvjnmsaeSfJQ5wjuFf2cs7ktb6E0Bx 6bwT6Ord0FeTjmtJuQi0QQrXWp5r4qCwoRRIFxEXFJcCBpUrv1XMAdcRj6So2Ao6PRx7 pLfnf6LIr2Pv3WMbzx5XYSUsALLMA8rFceCSxO82LlV8TiplkGrFAXZs5KcKkBFAYqi6 WshflsOD/xWhQbntsfqvwu/7PkMXY9xJv5fYczy2DbBdfTnw8nH3oVR8yXfkbwlcjWMC +dFw== X-Gm-Message-State: AOAM533ObTeQMmet4Fz6MnvnJo8axhiPc68LDokoZUK7bJtgOYHIS4rv RK7Y7RGoi6wek48H/zDuJ0vsRQ== X-Google-Smtp-Source: ABdhPJx0oUMZWVtlgj9lUn+RJPTG45aJ+hibkbpMvu4YotZivIMW/JM9715OgSgjMDC0h9JJxVMJvQ== X-Received: by 2002:a5d:9659:: with SMTP id d25mr792249ios.146.1615707922334; Sat, 13 Mar 2021 23:45:22 -0800 (PST) Received: from google.com ([2620:15c:183:200:fd93:7779:42e7:2899]) by smtp.gmail.com with ESMTPSA id a12sm4193650ilt.53.2021.03.13.23.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Mar 2021 23:45:21 -0800 (PST) Date: Sun, 14 Mar 2021 00:45:16 -0700 From: Yu Zhao To: Matthew Wilcox Cc: linux-mm@kvack.org, Alex Shi , Andrew Morton , Dave Hansen , Hillf Danton , Johannes Weiner , Joonsoo Kim , Mel Gorman , Michal Hocko , Roman Gushchin , Vlastimil Babka , Wei Yang , Yang Shi , Ying Huang , linux-kernel@vger.kernel.org, page-reclaim@google.com Subject: Re: [PATCH v1 01/14] include/linux/memcontrol.h: do not warn in page_memcg_rcu() if !CONFIG_MEMCG Message-ID: References: <20210313075747.3781593-1-yuzhao@google.com> <20210313075747.3781593-2-yuzhao@google.com> <20210313150918.GH2577561@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210313150918.GH2577561@casper.infradead.org> X-Stat-Signature: cmdwhctso8hyuumj8u1spqf11smwns3f X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 1FD7690009EA Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf19; identity=mailfrom; envelope-from=""; helo=mail-io1-f50.google.com; client-ip=209.85.166.50 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615707922-578876 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 Sat, Mar 13, 2021 at 03:09:18PM +0000, Matthew Wilcox wrote: > On Sat, Mar 13, 2021 at 12:57:34AM -0700, Yu Zhao wrote: > > We want to make sure the rcu lock is held while using > > page_memcg_rcu(). But having a WARN_ON_ONCE() in page_memcg_rcu() when > > !CONFIG_MEMCG is superfluous because of the following legit use case: > > > > memcg = lock_page_memcg(page1) > > (rcu_read_lock() if CONFIG_MEMCG=y) > > > > do something to page1 > > > > if (page_memcg_rcu(page2) == memcg) > > do something to page2 too as it cannot be migrated away from the > > memcg either. > > > > unlock_page_memcg(page1) > > (rcu_read_unlock() if CONFIG_MEMCG=y) > > > > This patch removes the WARN_ON_ONCE() from page_memcg_rcu() for the > > !CONFIG_MEMCG case. > > I think this is wrong. Usually we try to have the same locking > environment no matter what the CONFIG options are, like with > kmap_atomic(). I think lock_page_memcg() should disable RCU even if > CONFIG_MEMCG=n. I agree in principle. On this topic I often debate myself where to draw the line between being rigorous and paranoid. But in this particular case, I thought it's no brainer because, imo, most of the systems that don't use memcgs are small and preemptable, e.g., openwrt. They wouldn't appreciate a larger code size or rcu stalls due to preemptions of functions that take rcu locks just to be rigorous. This shouldn't be a problem if we only do so when CONFIG_DEBUG_VM=y, but then its test coverage is another question. I'd be happy to work out something in this direction, hopefully worth the trouble, if you think this compromise is acceptable.