Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp285511rdb; Sat, 19 Aug 2023 01:28:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHy8sL4LSoUvVwHAO/VTZfOL/zqNc7Sqi6sU1xHVIJ7c2H7CClb8BFdvmIhXtqufenuyest X-Received: by 2002:a05:6a20:938d:b0:137:23a2:2b3c with SMTP id x13-20020a056a20938d00b0013723a22b3cmr2167143pzh.49.1692433727854; Sat, 19 Aug 2023 01:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692433727; cv=none; d=google.com; s=arc-20160816; b=eImbLMaCliiYO/bNhbQE7BHx4mUs6P56tubt5NDqAZ5zx6UvYJdum81IxPbpMAF+ux B5V7ug9hqXsqyPv63ZIP/Rd/3AkY7EzPEjNXRnJ8UaYms0Sep6hcEjPieisoZ2gc57yU Ki2+bnHeszM9aqG8UB+DfRBMTUeI5RWng3z2QH2XPwqNaEKTGRdLTsRCs/hmdTTCGXSQ VnGVWFEdJU6x2WPeuoaviNh/LIjy5cBXyvi50hjBc2SeeuUFKRgVuSpdhDRa9SIeHfJM 9ra/CtmlI5M386VYJ2sjrDPzQjzjItthZRoSmUuXta967jfQg/91MVIAkRPPqD2swtK8 3CvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=TawkjbN36L2tJSa3Vtp7sv1FkX0qieEa0khYy9fqi68=; fh=dzECFDqx2BjqGiBvMh7sEDt2eccksfDF1IfNBC1hdiw=; b=uUhRbtPPi/okKU2YQfC0/5cH1iBL3XTNqngtyyCF/27kXrx64tduMPKJqCKeKx1jyk TOXZ6G1TBsMKTwLgLmWkZk6oNyEFofpqKpWAzoH5lE69sIoJ2VmkclrEgnW6AqHX/JNh KuOYCd99PFhzY3fuCMwGvosHqdtUtRA/gdZuU1PIwzQNlg2MyOVM5tUsOYg+Gifasc3n VfWUGvWPYxExEIHRMW8eJONzkhgFmhwTiRp9oHIjiAMglL80vnT/14C3MIl/KoeEeaXg 0FDx6PtpMWTRU60jO7L7LhZnR+AocR4iODSG2D06+dgfwqbwXZ6qcxk+6ECD0iZAWvKm h1EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GzVNpKWa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m1-20020a656a01000000b0055c868268f9si3337084pgu.462.2023.08.19.01.28.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 01:28:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GzVNpKWa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D83B34C0F; Sat, 19 Aug 2023 01:24:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238268AbjHOPqA (ORCPT + 99 others); Tue, 15 Aug 2023 11:46:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238283AbjHOPpp (ORCPT ); Tue, 15 Aug 2023 11:45:45 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6C89E61 for ; Tue, 15 Aug 2023 08:45:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692114300; 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=TawkjbN36L2tJSa3Vtp7sv1FkX0qieEa0khYy9fqi68=; b=GzVNpKWauBuwo5xlmYTiOTpaE75kyZKcq3hD2XfUMvFrqBbINHmFucLu/gZpeWVuB30XI1 5SAxRiSc8jU2IQHDEubTF65lIyKQfO80lX56Xw6+4jnWsqdcyl13TVvJYsVfdk8Ul3pySy i9gYzaGTq1QAceiu1zZlrjyQcxIZrdA= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-390-Tdg2iIrqNFaYgkrb_S-NTw-1; Tue, 15 Aug 2023 11:44:53 -0400 X-MC-Unique: Tdg2iIrqNFaYgkrb_S-NTw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8DC1529DD987; Tue, 15 Aug 2023 15:44:43 +0000 (UTC) Received: from [10.22.18.67] (unknown [10.22.18.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6AAEC15BAD; Tue, 15 Aug 2023 15:44:42 +0000 (UTC) Message-ID: <54e8c38d-c805-2666-b559-ce785ba24b67@redhat.com> Date: Tue, 15 Aug 2023 11:44:42 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH] mm: memcg: provide accurate stats for userspace reads Content-Language: en-US To: Tejun Heo , Yosry Ahmed Cc: Michal Hocko , Shakeel Butt , Johannes Weiner , Roman Gushchin , Andrew Morton , Muchun Song , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/14/23 20:35, Tejun Heo wrote: > Hello, > > On Mon, Aug 14, 2023 at 05:28:22PM -0700, Yosry Ahmed wrote: >>> So, the original design used mutex for synchronize flushing with the idea >>> being that updates are high freq but reads are low freq and can be >>> relatively slow. Using rstats for mm internal operations changed this >>> assumption quite a bit and we ended up switching that mutex with a lock. >> Naive question, do mutexes handle thundering herd problems better than >> spinlocks? I would assume so but I am not sure. > I don't know. We can ask Waiman if that becomes a problem. We had essentially solved the thundering herd problems for both spinlocks and mutexes. Both types of lock waiters will spin in their own cachelines (in the OSP wait queue in the case of mutex) except one that is at the head of the queue. So there should be minimal cacheline bouncing. One should certainly uses mutexes in sleep-able context or when the critical section is long. Cheers, Longman