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 X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10ED9C4360F for ; Mon, 25 Mar 2019 17:30:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D476B20896 for ; Mon, 25 Mar 2019 17:30:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UsO3kp6o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729489AbfCYRaw (ORCPT ); Mon, 25 Mar 2019 13:30:52 -0400 Received: from mail-yw1-f53.google.com ([209.85.161.53]:37505 "EHLO mail-yw1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728563AbfCYRaw (ORCPT ); Mon, 25 Mar 2019 13:30:52 -0400 Received: by mail-yw1-f53.google.com with SMTP id w66so7674370ywd.4; Mon, 25 Mar 2019 10:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bVfb/Fi+EfcnWQGedscfmZ5KsF8sXbJdykXnpkxBkGQ=; b=UsO3kp6o3hMhF14Y8VKKWc3iCQR7HfFb8xLn5AVpg1yscrK2bp+UaLiN/w2XwYKbpw RvhGHOLkeH1bFvMxr9ltHr5rOlLUx+lrRz0XzZ8KhtQP/pZjpAj9/mVmCHkEFZvykxN8 1zf6My3a974pQmkfLW5EY/SdoCUiiQZDr1dELIcEbdwF6Nd0xBTiqqOp76UKW2JUm0GL WTGtKu1xlYz/gueUtN9wXGNQY9rm0RelPNLg+KxDBiPTLsmmkKMqJCMQaIcp4QUYHpnI MxZ4HzgVFX8b+Kreg7DyYpQLpKv01TqQvvjtPV3HpxMSIzS0996LQaxiwqJHOA84Gs+B Mcig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bVfb/Fi+EfcnWQGedscfmZ5KsF8sXbJdykXnpkxBkGQ=; b=qlrNk0Z+/usH4vwI73R/AQfSdhF8AzH0bd6dclWps+KrnwMgZ96fSDL1rPAD4bZEOh jvPJN1hF8Misn8K/0zNxVbkAQ0wSwoeG3pUJPPOzWu1qucFpaZ3s1NJOM0T2oy/mv51a Ty5nxlRjaVK+xz7F3K2cxISusBLb4E+rKq5613XjyR5a5p7j3KUE2aRq04TLLJbGcUB0 7qHFHe0aTF/HsyqB1XZ10Q6AdAWPZQfa55m8Dpjp/hwLdh4S1bABI94cf4EVM1lGmij5 vZa4tHFsi4AhEtsnQMZadr/DjNUb40KuYm8z5aqjnGaUoP2Ojf/LZ6bpADywFqc2BesV kF+A== X-Gm-Message-State: APjAAAX5KKBpYVdFnM0A6fDFE2WgWs22cQ9NIIFcJ747gAbzZz5HIEz4 JLK4WFDnkrEJw6JviBeRMj/42bzjpzNmEio5gQOe8hzB X-Google-Smtp-Source: APXvYqzEeLXUcCXmrVki2BGbRB0Hh9PWWw8gd1e3VMc6YEVJW5IdKO/t1/yFqP30z3+XE61yLamojQGLccO6FWRqvsk= X-Received: by 2002:a81:7c4:: with SMTP id 187mr22204232ywh.176.1553535051514; Mon, 25 Mar 2019 10:30:51 -0700 (PDT) MIME-Version: 1.0 References: <20190325001044.GA23020@dastard> <20190325154731.GT1183@magnolia> <20190325164129.GH10344@bombadil.infradead.org> In-Reply-To: <20190325164129.GH10344@bombadil.infradead.org> From: Amir Goldstein Date: Mon, 25 Mar 2019 19:30:39 +0200 Message-ID: Subject: Re: [QUESTION] Long read latencies on mixed rw buffered IO To: Matthew Wilcox Cc: "Darrick J. Wong" , Dave Chinner , linux-xfs , Christoph Hellwig , linux-fsdevel Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Mon, Mar 25, 2019 at 6:41 PM Matthew Wilcox wrote: > > On Mon, Mar 25, 2019 at 08:47:31AM -0700, Darrick J. Wong wrote: > > Hmmm.... so it looks like the rw_semaphore behavior has shifted over > > time, then? > > Yes. > > > I thought rwsem was supposed to queue read and write waiters in order, > > at least on x86? Though I suppose that might not matter much since we > > can only run one writer at a time vs. waking up all the readers at once. > > Now I'm wondering if there ever was a time when the readers all got > > batched to the front and starved the writers, but eh I haven't drank > > enough coffee to remember things like that. :P > > > > (I wonder what would happen if rw_semaphore decided to wake up some > > number of the readers in the rwsem wait_list, not just the ones at the > > front...) > > rwsems currently allow a limited amount of queue-jumping; if a semaphore > is currently not acquired (it's in transition between two owners), a > running process can acquire it. > > I think it is a bug that we only wake readers at the front of the queue; > I think we would get better performance if we wake all readers. ie here: > > /* > - * Grant an infinite number of read locks to the readers at the front > - * of the queue. We know that woken will be at least 1 as we accounted > + * Grant an infinite number of read locks. We know that woken will > + * be at least 1 as we accounted > * for above. Note we increment the 'active part' of the count by the > * number of readers before waking any processes up. > */ > list_for_each_entry_safe(waiter, tmp, &sem->wait_list, list) { > struct task_struct *tsk; > > - if (waiter->type == RWSEM_WAITING_FOR_WRITE) > - break; > > Amir, it seems like you have a good test-case for trying this out ... Sure, but please explain. Why are you waking up the writers? Thanks, Amir.