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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EC93C83F11 for ; Mon, 28 Aug 2023 17:43:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E869C280023; Mon, 28 Aug 2023 13:43:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E36448E001C; Mon, 28 Aug 2023 13:43:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFF01280023; Mon, 28 Aug 2023 13:43:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C161C8E001C for ; Mon, 28 Aug 2023 13:43:18 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 80E141C94C5 for ; Mon, 28 Aug 2023 17:43:18 +0000 (UTC) X-FDA: 81174234876.14.02A5747 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 9BE52140039 for ; Mon, 28 Aug 2023 17:43:16 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AaDbtk1b; spf=pass (imf09.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693244596; h=from:from:sender: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:dkim-signature; bh=c86heriCzsgHv8Cr404S+ZS20rU8EPrOqgUpkTE5NMI=; b=ZGiKotBbV5rtQzOOaHRKNGTaXMz5ebpfOvDk0vcOu66hqlbn5+VCPWOZY0MreTy36Ks6Lj 0l8iQArtL0bL9dxfUF57y5oG4brYf6eUBXSTUXMgZT771rjH9GuRrtXnT6iDHz13qAQCQZ aG+Bu2KCRUZskrfGJw1cdgs69ggPGHY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693244596; a=rsa-sha256; cv=none; b=LAXpnHRVPsyRw+h3oYx9SuV011icFmBQA+56cK5RY/EjrLVLOM+KIfl8IZ20SoecU/KTwA 6PZPW2KmZFrY/pYZX7vo9JpMIeAjSwXOu1CzRmLMVWlMo4KQQfTxQj9t8RRHiQrpuIKWzR m53SBUe7Q251r4JakjCBj9dyzSFGgMM= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AaDbtk1b; spf=pass (imf09.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693244595; 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=c86heriCzsgHv8Cr404S+ZS20rU8EPrOqgUpkTE5NMI=; b=AaDbtk1bvaMB4Rir82EKeW6Xr4rOzQcFhR1Y8lY/rrn/Lsl98yv9Ro1CzxTDYg8DKyl0Xz jzWlfqGoa+99C9b22DPr7ufneEWsE7NEoiEovsbKwl+/ON3bPI37VY0VadJquCVR5esdlV +NqBf5YiLuyuojuFnr6fztXelsE2qu4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-571-mzQJchzgMYO4QXvwT8q-eA-1; Mon, 28 Aug 2023 13:43:10 -0400 X-MC-Unique: mzQJchzgMYO4QXvwT8q-eA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A1D52855710; Mon, 28 Aug 2023 17:43:09 +0000 (UTC) Received: from [10.22.18.125] (unknown [10.22.18.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF529401051; Mon, 28 Aug 2023 17:43:08 +0000 (UTC) Message-ID: <820843a5-d7a5-91a9-b861-99e7132ddb98@redhat.com> Date: Mon, 28 Aug 2023 13:43:08 -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 3/3] mm: memcg: use non-unified stats flushing for userspace reads Content-Language: en-US From: Waiman Long To: Yosry Ahmed Cc: Shakeel Butt , Michal Hocko , Andrew Morton , Johannes Weiner , Roman Gushchin , Muchun Song , Ivan Babrou , Tejun Heo , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230821205458.1764662-4-yosryahmed@google.com> <599b167c-deaf-4b92-aa8b-5767b8608483@redhat.com> <307cbcf6-dca2-0b5d-93e8-11368a931d2f@redhat.com> In-Reply-To: <307cbcf6-dca2-0b5d-93e8-11368a931d2f@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Queue-Id: 9BE52140039 X-Rspam-User: X-Stat-Signature: 98yij514cc34xohbge664de9rdbr37dw X-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t4tlWI5W3HlhjenQdh1XKPom7bOWMFJRu9xq5n3nI3cH1rUs3dMKiG2ZgickuCpaFbMyDB+WoXUUVeby0TGtOmPPVrp0DH2qjJfJz005NEQRknnfVlvWjYlLz6Q== 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 8/28/23 13:35, Waiman Long wrote: > On 8/28/23 13:28, Yosry Ahmed wrote: >> On Mon, Aug 28, 2023 at 10:27 AM Waiman Long wrote: >>> >>> On 8/28/23 13:07, Yosry Ahmed wrote: >>>>> Here I agree with you. Let's go with the approach which is easy to >>>>> undo for now. Though I prefer the new explicit interface for >>>>> flushing, >>>>> that step would be very hard to undo. Let's reevaluate if the >>>>> proposed >>>>> approach shows negative impact on production traffic and I think >>>>> Cloudflare folks can give us the results soon. >>>> Do you prefer we also switch to using a mutex (with preemption >>>> disabled) to avoid the scenario Michal described where flushers give >>>> up the lock and sleep resulting in an unbounded wait time in the worst >>>> case? >>> Locking with mutex with preemption disabled is an oxymoron. Use >>> spinlock >>> if you want to have preemption disabled. The purpose of usiing mutex is >>> to allow the lock owner to sleep, but you can't sleep with preemption >>> disabled. You need to enable preemption first. You can disable >>> preemption for a short time in a non-sleeping section of the lock >>> critical section, but I would not recommend disabling preemption for >>> the >>> whole critical section. >> I thought using a mutex with preemption disabled would at least allow >> waiters to sleep rather than spin, is this not correct (or doesn't >> matter) ? > > Because of optimistic spinning, a mutex lock waiter will only sleep if > the lock holder sleep or when its time slice run out. So the waiters > are likely to spin for quite a while before they go to sleep. Perhaps you can add a mutex at the read side so that only 1 reader can contend with the global rstat spinlock at any time if this is a concern. Regards, Longman