Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2112195pxj; Wed, 19 May 2021 23:55:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRndurAGKQVHxMHC9XC1SfGh88TEbfBYs3ylvRzTBx+gKd19XAdLGNdVaO7+qm5zF5vIzP X-Received: by 2002:a17:907:160a:: with SMTP id hb10mr3100939ejc.157.1621493729119; Wed, 19 May 2021 23:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621493729; cv=none; d=google.com; s=arc-20160816; b=dvoUoFqKpX3TLi80dks0HSGdZKzlUDPFw/hmxbLoiW92dSoj7GhI5pc+NPApvMpSUE XhFRap9HVIz0DpqqsHlKZRYXpJR+eZIlR0S6CHvNpGA97sRWqvfkxLAHRY5xOXZWeUbi nN8awvxqDnLyy/ruFKBdvuW0NciGDVjYuv9r1/UA0e4DEc7C41Qg7kcxwFXI+WLzeU66 jxN4E6Fgz1B5Vp8TDofN5JhjVcxr2crbXK9iAVAkHyt7vdoSgL0aHx29Icq1OMp/jxth r2DeI2ekOLHVfRMV7lPjk4WeOs5w9cP/aSdfR0MtPQ/5xr0dljd6qv94Pi+66EVwFj5j jd4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=rcGZDNyJ6vYh3nv1NbyctjSVuVLx0bLzs+7ceU1fwm4=; b=qeGgRMLKVcNaJZhUBjkp82upuqEcuqQQmO5H/GxuRCpwPz2/Q3mJ96yZkMLGHxB6p7 Pn2+Jkny5y7jl3nbZEnpNUY5uPtkWjALY/drbSUCbYglb4w0rMQnccD0iq069kNUzsdl t4dNJEPYm7cz89xK4sCIQA6wzE0pCM4IhBBow4qt6eCFeuE/eaAcvcDeTowxYnFHqtWw VtgeUHgvt1vEQMxjw4gC/kJ7IItp9YBdN1628+IZSgxdjmMdH7m/OGKk7iTFvNpXSKL+ 7H83Y1cq59HUi87p0yhhXAeZSzjzADmE44+qgKzYNGa0D99F26LL98sUyLP9L9hjjrKc I2ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=W+uE07db; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v22si1812087eja.614.2021.05.19.23.55.05; Wed, 19 May 2021 23:55:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=W+uE07db; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230392AbhETGzZ (ORCPT + 99 others); Thu, 20 May 2021 02:55:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbhETGzY (ORCPT ); Thu, 20 May 2021 02:55:24 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD592C061574 for ; Wed, 19 May 2021 23:54:02 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id h67-20020a25d0460000b0290517e5f14ba4so2155434ybg.18 for ; Wed, 19 May 2021 23:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=rcGZDNyJ6vYh3nv1NbyctjSVuVLx0bLzs+7ceU1fwm4=; b=W+uE07dbkPRm0EI7rt0odOA402xB5GM5xsOKzyKKjPQdnq9FzvuhBH2EmYJx+e3w2P M+GjA/Y/0N577Zt0vRn1fv9k1GS93aX/OLI3asM1EluD+bF6m15Qua90BDPhuN6RLdFt 9XaT7ugKFU1Zb0CN5pODFmCE1L4eWk8Idy1/MbWRtRICoOacDrCOBD3XXG+gene95EAz h6RenUUXrHuOEIq+2ZT1q6P10VKHqSaPsyoiUDDSBllpMLW3kYmkOWBQGnRaPndswvZ6 VxYMBaR/6WNfgBuQGLp6vrXdw55euSCrNkjy2sf+vVpzlTPTbCCa8UgSnsOUvdDUidvY K/+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=rcGZDNyJ6vYh3nv1NbyctjSVuVLx0bLzs+7ceU1fwm4=; b=jzFekar0HP/0GPy5CL4U72iLLcQoeWxnnbnFRr4z4BTc2/hrpionzQD3GXHT9lyHMR /YmLr75qJXGcWb0dXLEPIxzZ7UjTYADt32Jy07ZfWITJ2+jRh2k1W3Wgty9YjwFX9wmd /MWxRyZj/674SBQZu12SYNlqqqh/WZxiziHwdgJEnbvX2lzsMWl2I1dL0e+tJwPr9OlS sG5TsZvw0fciDahseafGyx4m1dmrCykPWBTkpCu+BJmF7Bt4PV/ogCZO0TIxn9ezbYr0 AkpMnHQnddjXudvfygGW20ymE3ieIKJU8hRbuF0+DfL6jdFdbczkyxRLk2dp6uiavglX Eajg== X-Gm-Message-State: AOAM533a36jLBDzDifmN467aiI0KlSL/85xe4UvoMJPjnzoeRbTl9eck Ndk0rslscVb76VSHIoD/Mmkup4p5pgk= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:595d:62ee:f08:8e83]) (user=yuzhao job=sendgmr) by 2002:a5b:b92:: with SMTP id l18mr5146859ybq.414.1621493641980; Wed, 19 May 2021 23:54:01 -0700 (PDT) Date: Thu, 20 May 2021 00:53:42 -0600 In-Reply-To: <20210520065355.2736558-1-yuzhao@google.com> Message-Id: <20210520065355.2736558-2-yuzhao@google.com> Mime-Version: 1.0 References: <20210520065355.2736558-1-yuzhao@google.com> X-Mailer: git-send-email 2.31.1.751.gd2f1c929bd-goog Subject: [PATCH v3 01/14] include/linux/memcontrol.h: do not warn in page_memcg_rcu() if !CONFIG_MEMCG From: Yu Zhao To: linux-mm@kvack.org Cc: Alex Shi , Andi Kleen , Andrew Morton , Dave Chinner , Dave Hansen , Donald Carr , Hillf Danton , Jens Axboe , Johannes Weiner , Jonathan Corbet , Joonsoo Kim , Konstantin Kharlamov , Marcus Seyfarth , Matthew Wilcox , Mel Gorman , Miaohe Lin , Michael Larabel , Michal Hocko , Michel Lespinasse , Rik van Riel , Roman Gushchin , Tim Chen , Vlastimil Babka , Yang Shi , Ying Huang , Zi Yan , linux-kernel@vger.kernel.org, lkp@lists.01.org, page-reclaim@google.com, Yu Zhao , Konstantin Kharlamov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org page_memcg_rcu() warns on !rcu_read_lock_held() regardless of CONFIG_MEMCG. The following legit code trips the warning when !CONFIG_MEMCG, since lock_page_memcg() and unlock_page_memcg() are empty for this config. 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) Locking/unlocking rcu consistently for both configs is rigorous but it also forces unnecessary locking upon users who have no interest in CONFIG_MEMCG. This patch removes the assertion for !CONFIG_MEMCG, because page_memcg_rcu() has a few callers and there are no concerns regarding their correctness at the moment. Signed-off-by: Yu Zhao Tested-by: Konstantin Kharlamov --- include/linux/memcontrol.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index c193be760709..6bcac3d91dd1 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1131,7 +1131,6 @@ static inline struct mem_cgroup *page_memcg(struct page *page) static inline struct mem_cgroup *page_memcg_rcu(struct page *page) { - WARN_ON_ONCE(!rcu_read_lock_held()); return NULL; } -- 2.31.1.751.gd2f1c929bd-goog