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 EE1DBC433F5 for ; Fri, 17 Dec 2021 17:50:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D7246B0071; Fri, 17 Dec 2021 12:50:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 485456B0073; Fri, 17 Dec 2021 12:50:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 327376B0074; Fri, 17 Dec 2021 12:50:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0193.hostedemail.com [216.40.44.193]) by kanga.kvack.org (Postfix) with ESMTP id 251906B0071 for ; Fri, 17 Dec 2021 12:50:11 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E1A69180D01BB for ; Fri, 17 Dec 2021 17:50:00 +0000 (UTC) X-FDA: 78928024560.12.6A75712 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 646D720006 for ; Fri, 17 Dec 2021 17:50:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639763399; 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=hH32Mr09T44842vxV3B7WrEoq/VpUbXtp4OtPbsiQ8A=; b=ekgU7oKJPxUn/DkFMAl+zf79Dv7O/LulHkSnB4hs4KPj4q8R86qzPuP0ewh3XdfztxaziJ PSLLq50ArS10MiTLo0FM/lmE88wc+o0u5GFKUh4mkFZCheOSHifUmeyF73NymFdZe83OWA 4WRX29EC8u2wmluB2CWc2kChn0toDL4= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-475-44CAN-Q0NxaDCeumyjIiFQ-1; Fri, 17 Dec 2021 12:49:56 -0500 X-MC-Unique: 44CAN-Q0NxaDCeumyjIiFQ-1 Received: by mail-wm1-f71.google.com with SMTP id l4-20020a05600c1d0400b00332f47a0fa3so1374765wms.8 for ; Fri, 17 Dec 2021 09:49:56 -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:from:to:cc:references:organization:in-reply-to :content-transfer-encoding; bh=hH32Mr09T44842vxV3B7WrEoq/VpUbXtp4OtPbsiQ8A=; b=04HpJ5q6/nXP3EGMj37/iHZoUx950jH5lYyJenKO8zGjWR8/ONOW1jTlIA8mG4C9oD tXBXbH5GziAkuIgqegaOy/AATkSYRKilHzXjROdRzSFLoAr2/X2X+ZM701L8+MLM2gxs FWcQT2HDnB319A0nuX6OOSMyRF4hRSm35/ZHJX3ykiQVm2SP4OwHZ9RbkPbhEjXVbjaF B7hv1OhfN/OhM79/a6l/Hcr1RqOGaOZGFS0M0sHU75yVL841Naf9Tn+sB4QfElB12ZmX ild6qD5C8DyLFeB45w8UkPQwsnxIYx8HmRR7M/CMeSRpChfvpd7BPWFUv8IprI9QoCwL Gq+w== X-Gm-Message-State: AOAM530TibC7owjKrjHvTG3IGSKc78Be0g9QRrmQBf3kwL0Mrr/l8rz4 3dRQgSyo54o/CDVSU+NdrOWBKAmQW3+36vAAo/vN0e2q1B7k0qQpQKB2s26xmezV6SrcmNalD+6 0munARLuT8QM= X-Received: by 2002:adf:e0cd:: with SMTP id m13mr906515wri.128.1639763395435; Fri, 17 Dec 2021 09:49:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyaFASAHJrtnfsNBUE2d+KqbUAQa6kV/aLZsG8AH+xUC0YXxdgETnWUDGLNs6zv4pSGuzN60g== X-Received: by 2002:adf:e0cd:: with SMTP id m13mr906488wri.128.1639763395173; Fri, 17 Dec 2021 09:49:55 -0800 (PST) Received: from [192.168.3.132] (p4ff234b8.dip0.t-ipconnect.de. [79.242.52.184]) by smtp.gmail.com with ESMTPSA id bh16sm12335864wmb.1.2021.12.17.09.49.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Dec 2021 09:49:54 -0800 (PST) Message-ID: Date: Fri, 17 Dec 2021 18:49:50 +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 v1 01/11] seqlock: provide lockdep-free raw_seqcount_t variant From: David Hildenbrand To: Nadav Amit Cc: LKML , Andrew Morton , Hugh Dickins , Linus Torvalds , David Rientjes , Shakeel Butt , John Hubbard , Jason Gunthorpe , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Matthew Wilcox , Vlastimil Babka , Jann Horn , Michal Hocko , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , "linux-mm@kvack.org" , "linux-kselftest@vger.kernel.org" , "linux-doc@vger.kernel.org" , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , Jonathan Corbet References: <20211217113049.23850-1-david@redhat.com> <20211217113049.23850-2-david@redhat.com> <38BCB153-7E7C-4AAD-8657-E5C6F9E1EF9B@vmware.com> <058e97eb-1489-3d59-c6ee-94175dc13134@redhat.com> Organization: Red Hat In-Reply-To: <058e97eb-1489-3d59-c6ee-94175dc13134@redhat.com> 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 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ekgU7oKJ; spf=none (imf03.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Queue-Id: 646D720006 X-Stat-Signature: kudp9eob9dontfjqqdzpaujnzh4guwgp X-Rspamd-Server: rspam04 X-HE-Tag: 1639763400-998878 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 17.12.21 18:29, David Hildenbrand wrote: > On 17.12.21 18:02, Nadav Amit wrote: >> >> >>> On Dec 17, 2021, at 3:30 AM, David Hildenbrand wrote: >>> >>> Sometimes it is required to have a seqcount implementation that uses >>> a structure with a fixed and minimal size -- just a bare unsigned int -- >>> independent of the kernel configuration. This is especially valuable, when >>> the raw_ variants of the seqlock function will be used and the additional >>> lockdep part of the seqcount_t structure remains essentially unused. >>> >>> Let's provide a lockdep-free raw_seqcount_t variant that can be used via >>> the raw functions to have a basic seqlock. >>> >>> The target use case is embedding a raw_seqcount_t in the "struct page", >>> where we really want a minimal size and cannot tolerate a sudden grow of >>> the seqcount_t structure resulting in a significant "struct page" >>> increase or even a layout change. >>> >>> Provide raw_read_seqcount_retry(), to make it easy to match to >>> raw_read_seqcount_begin() in the code. >>> >>> Let's add a short documentation as well. >>> >>> Note: There might be other possible users for raw_seqcount_t where the >>> lockdep part might be completely unused and just wastes memory -- >>> essentially any users that only use the raw_ function variants. >>> >> >> Is it possible to force some policy when raw_seqcount_t is used to >> prevent its abuse? For instance not to allow to acquire other (certain?) >> locks when it is held? >> > > Good question ... in this series we won't be taking additional locks on > the reader or the writer side. Something like lockdep_forbid() / > lockdep_allow() to disallow any kind of locking. I haven't heard of > anything like that, maybe someone reading along has a clue? > > The writer side might be easy to handle, but some seqcount operations > that don't do the full read()->retry() cycle are problematic > (->raw_read_seqcount). Sorry, I forgot to mention an important point: the raw_seqcount_t doesn't give you any additional "power" to abuse. You can just use the ordinary seqcount_t with the raw_ functions. One example is mm->write_protect_seq . So whatever we would want to "invent" should also apply to the raw_ functions in general -- which might be undesired or impossible (IIRC IRQ context). -- Thanks, David / dhildenb