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 92175C83F11 for ; Mon, 28 Aug 2023 17:35:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 026B18E002A; Mon, 28 Aug 2023 13:35:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF28D8E001C; Mon, 28 Aug 2023 13:35:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6C0C8E002A; Mon, 28 Aug 2023 13:35:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C29B18E001C for ; Mon, 28 Aug 2023 13:35:18 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8E8C812029C for ; Mon, 28 Aug 2023 17:35:18 +0000 (UTC) X-FDA: 81174214716.30.E4257C7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id A0B9114001E for ; Mon, 28 Aug 2023 17:35:16 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BnQ6WDIa; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693244116; 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=lp7Jngb3Bq5sfpUloEsFy1w1y656mR7FgAQcm/Q5BbE=; b=43IrYNrBV8I+Ocfa8IUxOYlFnvynAPIjzL58WnY+Orb+OBwK/jVJqbxILZIWhLS/OfvZ9v Huj92Qh2/S+ylviXARGylrXpMfl/zwAZAT6Elp+a7klrBVEGgDfA8nYCDa9x+E+IoPtxJi 70ShUjB2m0gH6wwI68mYkKobyq03M+8= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BnQ6WDIa; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693244116; a=rsa-sha256; cv=none; b=lnWCDhyBC4UeMWA3aM5oZUeOhhnNM5BwrA8w391Fvq5klk42C7XZ3sn5PvJw/YT9pW4C6e DplN9Bm6GLkBMngSsyRqnF+pAi/tpUGpoHmJ4UMwFhwQyKg5QYJ9LIjhVsrmDaeuzEUx2+ 39BX+c/MqzWVxbe7laCFI/6kiggFzgM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693244116; 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=lp7Jngb3Bq5sfpUloEsFy1w1y656mR7FgAQcm/Q5BbE=; b=BnQ6WDIass9ziI28dHm/YZODmgv22PJ08rdPbSgslEVpCU4CfPTQWVTmNW+vxDQbiLTRHB zsJFIY11JxG3Eg47K36UC7XVGukD7WziaBud97/3PWuFFWfRY2GLNY2AilYwMLq7N4DJEP a++xCbpXH+WSSiiPOQgffwMWcgO+OiU= 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-7-eNz7C1GRO5CeC6yhQnnJxA-1; Mon, 28 Aug 2023 13:35:10 -0400 X-MC-Unique: eNz7C1GRO5CeC6yhQnnJxA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B79B7185A794; Mon, 28 Aug 2023 17:35:09 +0000 (UTC) Received: from [10.22.18.125] (unknown [10.22.18.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 209D02166B25; Mon, 28 Aug 2023 17:35:09 +0000 (UTC) Message-ID: <307cbcf6-dca2-0b5d-93e8-11368a931d2f@redhat.com> Date: Mon, 28 Aug 2023 13:35: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 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> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspamd-Queue-Id: A0B9114001E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: q9196g84rrjoyj49wb57c6hq3m5e63br X-HE-Tag: 1693244116-931859 X-HE-Meta: U2FsdGVkX1/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49nRe7NxpCGqY6i8Vl4SBsBfcIOjMLd6+FQputWFmEakU3PloJRHeB/k2VTGBZS1yfbY1Bi4ABsrQGjBB4FJKqpcso2ai2EmXQ/WwUw== 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: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. Cheers, Longman