Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5483006rwb; Tue, 17 Jan 2023 14:34:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXupkATEUhCMCDE4/ul4w0GS6c+sMJAbbD6wuZj60llVbAR9eUHUJaE/NO/lVxwxyxkTv4LH X-Received: by 2002:a05:6a20:d68c:b0:b8:65b8:6a4e with SMTP id it12-20020a056a20d68c00b000b865b86a4emr5249382pzb.45.1673994854003; Tue, 17 Jan 2023 14:34:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673994853; cv=none; d=google.com; s=arc-20160816; b=q5Y4Kxo4flvSdLgrcWV+jHyYACSeLN7+kVYC6f8qM5CpUwmZhRaAipLxLe3wg6gyxt u5VXAWC40+YJlpYQBDyV/iCc6PomPTl6T9104nYqw1F4empcvJat3yEL6e8d4CbkFNBQ kq9qbbW+1kAQUqP5xwOPVHDPkIIY7NV5WY5VJSF3UH1DSGdniaRnQ+kimzIHL1oYAHUF 8kwaBfEpAoDz5RR8wAu5FBUWLTSRf1GaiNaYx/ci1pHWogZMIlJtFZu5Kmp6YEwkeI05 aKLPVHUHwNSM15RKSYvHA8vYqmbjpNBskWCXwlZW03LXyIMjLI4d1yc4knWlz7t/R00z hR4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=joReDe9zN9w1YbYxniPhXt3I9ej9se2S9PgCXccJZHs=; b=cyMRfOaWGsus82WOlTADCA9Afq4h+hM2GlASFydM9jLNvUwxQ04qRol6AaIWrOBLvD 0AEPPe90duEBiKLLWjXHHzIpJdR7Yjk12c76AYcKkZF0Vm1G1Pr+KwaTlks6BoVecyhl +Yhr+KlP69AysHomFq1tITTrS72jbSWP6LVhinfQM+qC1sn5MX4CcvMDcrYVu9h8mpXD JJZ0e9E9O7AQgrH/Fjhq880kIk/0dta3BbI38IPTXO969vnB+cn9iLC8HpeWAEM7PK6D EA0wasbPXzyv3TMs09ZYkNUKMZO7Zr2HSw7YOqiyXGMPiZaBlONwdL51Tzl7G8n38LIN QF8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=ZnVDnkua; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k191-20020a6384c8000000b004cf6f7d04c1si2423680pgd.341.2023.01.17.14.34.08; Tue, 17 Jan 2023 14:34:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=ZnVDnkua; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229712AbjAQWDe (ORCPT + 46 others); Tue, 17 Jan 2023 17:03:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbjAQWB3 (ORCPT ); Tue, 17 Jan 2023 17:01:29 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E28436086 for ; Tue, 17 Jan 2023 12:31:55 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3052820134; Tue, 17 Jan 2023 20:31:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1673987514; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=joReDe9zN9w1YbYxniPhXt3I9ej9se2S9PgCXccJZHs=; b=ZnVDnkua6Rig0sjcQadxKq0ryHwmSAL+lKO2BmXT1OTYGtdMUGkXDMDN6J+YG9zfjL89u3 rCuLgOCpx9WwTGjuibJuxPjmq8QFr2ZqlYetoHt7qEV7RfZRKGoPz3LIShyUKReHOUX0uo 4Fubk0RUBcIux8DmR6q/Jzb84/zr7Ak= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 061B313357; Tue, 17 Jan 2023 20:31:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 1ygGAboFx2OEYQAAMHmgww (envelope-from ); Tue, 17 Jan 2023 20:31:54 +0000 Date: Tue, 17 Jan 2023 21:31:51 +0100 From: Michal Hocko To: Suren Baghdasaryan Cc: Matthew Wilcox , Hyeonggon Yoo <42.hyeyoo@gmail.com>, akpm@linux-foundation.org, michel@lespinasse.org, jglisse@google.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, paulmck@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, hughlynch@google.com, leewalsh@google.com, posk@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock Message-ID: References: <20230109205336.3665937-1-surenb@google.com> <20230109205336.3665937-42-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 17-01-23 10:28:40, Suren Baghdasaryan wrote: [...] > > Then yes, that's a starvable lock. Preventing starvation on the mmap > > sem was the original motivation for making rwsems non-starvable, so > > changing that behaviour now seems like a bad idea. For efficiency, I'd > > suggest that a waiting writer set the top bit of the counter. That way, > > all new readers will back off without needing to check a second variable > > and old readers will know that they *may* need to do the wakeup when > > atomic_sub_return_release() is negative. > > > > (rwsem.c has a more complex bitfield, but I don't think we need to go > > that far; the important point is that the waiting writer indicates its > > presence in the count field so that readers can modify their behaviour) > > Got it. Ok, I think we can figure something out to check if there are > waiting write-lockers and prevent new readers from taking the lock. Reinventing locking primitives is a ticket to weird bugs. I would stick with the rwsem and deal with performance fallouts after it is clear that the core idea is generally acceptable and based on actual real life numbers. This whole thing is quite big enough that we do not have to go through "is this new synchronization primitive correct and behaving reasonably" exercise. -- Michal Hocko SUSE Labs