Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3387674pxu; Tue, 15 Dec 2020 06:03:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqjNT45aDi6h0m24WXXT4oRjFfo6MB21H4milhcpjgZzmYbEcZx571lf46h01CloK+2BKD X-Received: by 2002:aa7:dac5:: with SMTP id x5mr30232369eds.198.1608040981682; Tue, 15 Dec 2020 06:03:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608040981; cv=none; d=google.com; s=arc-20160816; b=rsFV1znli6EHIHHofmKnOepWrC2m5+Q1wHP/c4IPW6dBusA18eByDRAy2/wXIp5FSJ pHmZN8Ct9EL9dusTXGpiDnhuE1dchfvpP8d6ETaSTKvC4k4rnroL68JCkqS05mYW6wZg ZQjCPgshbF8GWP3gsPb2G3DYsVkYpcBKqpy84W1K839/sBm16N1onrJ7iGHSwtJTKIbm dpIxysBA17EyS6tPpHv/wqW95mb4yxU+plsXDoueooR60mGgE8JsYWhEtwvwKXYuuYZS MFrl+sDhV2QZmMCpYfXa9lXK4p66ZAvS5GwJAIplZI4hrW7bfaNVZKVjLJVlnrO7Ylln TMUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=28yftlhd5Mm7TNEoJztkfUFW7tsicxqlvZ58WZP092o=; b=ezATCNn1QGueIUY7knmZl8cdtDWLsvM7oAix5+VO+zWgs4LQAlVgEODwd/iKc1kNbW cHi5ooIpUuSktHZW4nSoRNW6jnKdgjmoMlzGX100vE3kYag0kFtoUkLdhkVY4Dr2EP7U DSqCs4wYq3nqrkKQRkKB+pYiZ6eTr5nx8t8VXt7/W3xSmzKswhg10uHNOnqD9YBBA4zh H2gcHSj7fUq2IwcjGYjWL4YXxjJqWvI34fbB4qifi8Dm+4aOf41fsevMpWsqCoQ+OFqG wo51Y8r1ErlH8DPNC3s4RFm0rcdnz0N/yR839gBRf8GBExsr03w7a0U8s9w0/S+khf+x 1A0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=q8hRvO8F; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq1si829952ejc.530.2020.12.15.06.02.31; Tue, 15 Dec 2020 06:03:01 -0800 (PST) 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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=q8hRvO8F; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729066AbgLON44 (ORCPT + 99 others); Tue, 15 Dec 2020 08:56:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728975AbgLON4i (ORCPT ); Tue, 15 Dec 2020 08:56:38 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76579C0617A6 for ; Tue, 15 Dec 2020 05:55:57 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id cm17so21122111edb.4 for ; Tue, 15 Dec 2020 05:55:57 -0800 (PST) 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=28yftlhd5Mm7TNEoJztkfUFW7tsicxqlvZ58WZP092o=; b=q8hRvO8FBlmEVVvGDqqdPymPT2VZCrOP6sdFOK85a8fzhGrEA+VPk8dRAl38JbXfAb pENLRXdI7wPSCGKgFbDvGVqnbbRQ1YJqOZGobDdUJevwJgsecLQ0xYQyU1R7BaKyJOAm aU8bjNtF5rSo+WjA633Q3G4UZXiJdP0mgMratYIzEVUbz4Yd3ALFdCr3qnjEbsQ7KGLI gl3imdIUYwv7AEAmQMNJsX0f1SFP7S+DAL7TLK0FN0FaOdsxR875O0AgQ0WZrUXnMyu3 DYN8kHD7MtuD2z7RUKB5HUtduTjGtX3FHHdlziaVIJaOq47v8MTpI4KmaMgWA4Y5/SWe RpNg== 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=28yftlhd5Mm7TNEoJztkfUFW7tsicxqlvZ58WZP092o=; b=lyRtK7HutDcwDViL4Dc2wfr2x8DWKAChj44J1tvUxlLZZSagx2M39li4TD4i1ri0a4 jfCwCB6jXHSCYx4s0mqbPSebV3rfDSm6MAKg2qSUDdRx72jttxDb6/VKDeSdQiyy9tYM cwOgcxA10j3t2LrJXJA606DA7paWL+wNV5DAdLZeTBTj4x4akyF04So3ATgUG6DAfaa7 nC8PLH686Dh5EYdIsERNugvCNL+iDclvoRSvtYn+5VLWawhlsaW+F2mZdcuB44Li1Usl 6Jmi0494Hhb5b4H4uWRDOPtTAIUYV2Ik/E4249td8XTPofN8MZzCTTpgC36FO/NcbZHb 6j5g== X-Gm-Message-State: AOAM532Sc7/1zlToQs49Pqjwn+svdZkc+fF6jsarYVNPN8lR5IghrFpA ptlYuOj+lF5xprSbmGF44Phn4A== X-Received: by 2002:a05:6402:2066:: with SMTP id bd6mr29548060edb.211.1608040556150; Tue, 15 Dec 2020 05:55:56 -0800 (PST) Received: from localhost ([2620:10d:c093:400::5:d6dd]) by smtp.gmail.com with ESMTPSA id b21sm18147895edr.53.2020.12.15.05.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 05:55:55 -0800 (PST) Date: Tue, 15 Dec 2020 14:53:48 +0100 From: Johannes Weiner To: Dave Chinner Cc: Yang Shi , guro@fb.com, ktkhai@virtuozzo.com, shakeelb@google.com, mhocko@suse.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [v2 PATCH 2/9] mm: memcontrol: use shrinker_rwsem to protect shrinker_maps allocation Message-ID: <20201215135348.GC379720@cmpxchg.org> References: <20201214223722.232537-1-shy828301@gmail.com> <20201214223722.232537-3-shy828301@gmail.com> <20201215020957.GK3913616@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201215020957.GK3913616@dread.disaster.area> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 15, 2020 at 01:09:57PM +1100, Dave Chinner wrote: > On Mon, Dec 14, 2020 at 02:37:15PM -0800, Yang Shi wrote: > > Since memcg_shrinker_map_size just can be changd under holding shrinker_rwsem > > exclusively, the read side can be protected by holding read lock, so it sounds > > superfluous to have a dedicated mutex. > > I'm not sure this is a good idea. This couples the shrinker > infrastructure to internal details of how cgroups are initialised > and managed. Sure, certain operations might be done in certain > shrinker lock contexts, but that doesn't mean we should share global > locks across otherwise independent subsystems.... They're not independent subsystems. Most of the memory controller is an extension of core VM operations that is fairly difficult to understand outside the context of those operations. Then there are a limited number of entry points from the cgroup interface. We used to have our own locks for core VM structures (private page lock e.g.) to coordinate VM and cgroup, and that was mostly unintelligble. We have since established that those two components coordinate with native VM locking and lifetime management. If you need to lock the page, you lock the page - instead of having all VM paths that already hold the page lock acquire a nested lock to exclude one cgroup path. In this case, we have auxiliary shrinker data, subject to shrinker lifetime and exclusion rules. It's much easier to understand that cgroup creation needs a stable shrinker list (shrinker_rwsem) to manage this data, than having an aliased lock that is private to the memcg callbacks and obscures this real interdependency.