From mboxrd@z Thu Jan 1 00:00:00 1970 From: Waiman Long Subject: Re: [PATCH 3/3] mm: memcg: use non-unified stats flushing for userspace reads Date: Mon, 28 Aug 2023 13:35:08 -0400 Message-ID: <307cbcf6-dca2-0b5d-93e8-11368a931d2f@redhat.com> References: <20230821205458.1764662-4-yosryahmed@google.com> <599b167c-deaf-4b92-aa8b-5767b8608483@redhat.com> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693244112; 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=BoBqtkksSmZH0rC828ceJ3kT+CNe82fMNYv7EyjWVkrM6ruYuDdDOxDcc28Q0eVYPN0st+ akmBQVCWG4jQ4EMWS7D1FlgCEhs6ldPtHUfv5m5Bv+UvOqFzJqsRfwUuiIsl1q1WH01mml yuaRp9le10nfBS0IjUYAB24rmDsuHI4= Content-Language: en-US In-Reply-To: List-ID: Content-Type: text/plain; charset="windows-1252"; format="flowed" To: Yosry Ahmed Cc: Shakeel Butt , Michal Hocko , Andrew Morton , Johannes Weiner , Roman Gushchin , Muchun Song , Ivan Babrou , Tejun Heo , linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On 8/28/23 13:28, Yosry Ahmed wrote: > On Mon, Aug 28, 2023 at 10:27=E2=80=AFAM 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=20 the lock holder sleep or when its time slice run out. So the waiters are=20 likely to spin for quite a while before they go to sleep. Cheers, Longman