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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09325C83F11 for ; Mon, 28 Aug 2023 17:44:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232910AbjH1RoZ (ORCPT ); Mon, 28 Aug 2023 13:44:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232930AbjH1RoB (ORCPT ); Mon, 28 Aug 2023 13:44:01 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 975FCEE for ; Mon, 28 Aug 2023 10:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693244597; 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=LOrd24esMDViOwYvhMfX2i12uiF/uSaktHezs+EP9laiojMEZi4vsBqNmkSEKZUWKw5YPC eJWMv6J+Ix1FFpVUTTRLRdU4XCwnevBB9X/tEVDfzdMcG1II8XHUT8Z3/RgPZq5TPHOQN+ FLBzgxTGbkpUt5zXztH1paPoH44yW5U= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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