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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4973C433EF for ; Wed, 10 Nov 2021 16:54:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5B87361241 for ; Wed, 10 Nov 2021 16:54:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5B87361241 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id B167D6B006C; Wed, 10 Nov 2021 11:54:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AC6346B0071; Wed, 10 Nov 2021 11:54:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B5596B0072; Wed, 10 Nov 2021 11:54:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id 8CE686B006C for ; Wed, 10 Nov 2021 11:54:05 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5102A183D2A03 for ; Wed, 10 Nov 2021 16:54:05 +0000 (UTC) X-FDA: 78793618050.24.37FAB06 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 9C46090000B6 for ; Wed, 10 Nov 2021 16:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636563244; 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=3skehNDJHqZFHvrdLObhkU+zt+1yZ5NMVqO6+J/UxgE=; b=FUXKpHYKKgWOEf+hXBC7fkdmXl911tGiGaltyLaOyA0aXJKccjpe7ZM4Wi6cR2GN13M39X paG51Wk5WVyD6u2wptyNIYKFtJONrl3/w0uvBm+zIykEQPUhMan/riSd6ocFvJcOBMtDfZ JjiKT9IdLRqoNoBXT+IUgf2HksbKOjA= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-582-H-0FrX1pOAS-1bDkthok9w-1; Wed, 10 Nov 2021 11:54:00 -0500 X-MC-Unique: H-0FrX1pOAS-1bDkthok9w-1 Received: by mail-wm1-f71.google.com with SMTP id b145-20020a1c8097000000b003335872db8dso781622wmd.2 for ; Wed, 10 Nov 2021 08:54:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=3skehNDJHqZFHvrdLObhkU+zt+1yZ5NMVqO6+J/UxgE=; b=t7sgrtIsg/96jf4g+v7cuDfQfsd+DooRYd+UR32nZfXq0v5frP56vqAqrhN73sE0Ku WQ9Qt6P4jCx2bEJ8v0/rDhShMvf/bxm7Skgj+mDYUVpxWxoztjbPLYLkWbClcF5O20nW rQ8MGqSmRIhTrIDIVGij/uY/h+k2ZdkBTVWaKk8fy8j5eHOiHJ50+0Mf3mA/ClTky1y9 n5FN9Nf5efuSXqhUZXIf+R8DGENor0s1mB8Uek6ZBF0jU656d528cN3NU/bimERz1FaQ CQ8l8wl+c6IKNxT75HXKILbZfrJqYvcO+fK1nE8qKDLlsft8uBSEJrSp9MNdVNqBNL2b epKQ== X-Gm-Message-State: AOAM531ZQ3FjI7RCHS3/cDVyf0ul5iSmR6tCbpWOeFlxm3JKP9bDFlSM 2UT12Dc5YSpfEdydFfcJ9TRHZ2skAq2rguSVgSQWe5Spdwgqbr+RDGQzTQNI/Q58OVe5dXkjgQa IS3EVolRDqj4= X-Received: by 2002:a5d:59ab:: with SMTP id p11mr541383wrr.340.1636563239612; Wed, 10 Nov 2021 08:53:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmw7VPt89V/wQDpl+r2pm834mtB3sAdR7mcz3Tn1FXjAMGhv2J/CUV7Ygff/myU9JVf71JCw== X-Received: by 2002:a5d:59ab:: with SMTP id p11mr541350wrr.340.1636563239362; Wed, 10 Nov 2021 08:53:59 -0800 (PST) Received: from [192.168.3.132] (p5b0c604f.dip0.t-ipconnect.de. [91.12.96.79]) by smtp.gmail.com with ESMTPSA id n8sm363484wrp.95.2021.11.10.08.53.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Nov 2021 08:53:58 -0800 (PST) Message-ID: Date: Wed, 10 Nov 2021 17:53:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH v3 00/15] Free user PTE page table pages To: Matthew Wilcox Cc: Jason Gunthorpe , Qi Zheng , akpm@linux-foundation.org, tglx@linutronix.de, kirill.shutemov@linux.intel.com, mika.penttila@nextfour.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, songmuchun@bytedance.com, zhouchengming@bytedance.com References: <20211110105428.32458-1-zhengqi.arch@bytedance.com> <20211110125601.GQ1740502@nvidia.com> <8d0bc258-58ba-52c5-2e0d-a588489f2572@redhat.com> <20211110143859.GS1740502@nvidia.com> <6ac9cc0d-7dea-0e19-51b3-625ec6561ac7@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9C46090000B6 X-Stat-Signature: mx6ennxntcex6ix6k5asmxspubzr3yw1 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FUXKpHYK; spf=none (imf23.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1636563229-850219 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 10.11.21 17:49, Matthew Wilcox wrote: > On Wed, Nov 10, 2021 at 04:37:14PM +0100, David Hildenbrand wrote: >>> I'd suggest to make this new lock a special rwsem which allows either >>> concurrent read access OR concurrent PTL access, but not both. This >> >> I looked into such a lock recently in similar context and something like >> that does not exist yet (and fairness will be challenging). You either >> have a single reader or multiple writer. I'd be interested if someone >> knows of something like that. > > We've talked about having such a lock before for filesystems which want > to permit either many direct-IO accesses or many buffered-IO accesses, but > want to exclude a mixture of direct-IO and buffered-IO. The name we came > up with for such a lock was the red-blue lock. Either Team Red has the > lock, or Team Blue has the lock (or it's free). Indicate free with velue > zero, Team Red with positive numbers and Team Blue with negative numbers. > If we need to indicate an opposing team is waiting for the semaphore, > we can use a high bit (1 << 30) to indicate no new team members can > acquire the lock. Not sure whether anybody ever coded it up. Interesting, thanks for sharing! My excessive google search didn't reveal anything back then (~3 months ago) -- only questions on popular coding websites asking essentially for the same thing without any helpful replies. But maybe I used the wrong keywords (e.g., "multiple reader, multiple writer", I certainly didn't search for "red-blue lock", but I do like the name :) ). Fairness might still be the biggest issue, but I am certainly no locking expert. -- Thanks, David / dhildenb