Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2029468ybb; Sat, 4 Apr 2020 19:48:30 -0700 (PDT) X-Google-Smtp-Source: APiQypInAxErDGIBH4m7RNulGY+vfWVXOtGPq1XelSwNoSU79Y/J8DHnGEC1R7lkMzAwRdGOY6V+ X-Received: by 2002:aca:7285:: with SMTP id p127mr8196120oic.32.1586054910651; Sat, 04 Apr 2020 19:48:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586054910; cv=none; d=google.com; s=arc-20160816; b=lskkJNRdqr5ED23ImJ0t38D6ITOioRVh4v5lzxURq4qr2iDj8SYoaURuP7BP27TPYh 3KWCfYSxBvEqT+7/qz591kda1OyQO59C5/V8DDI0SI1r6i5yFANFpRXJlYJBSl85zAUw DW9BtHu2AQPlqm9rISYbAPXxVagATrLfEB8/a60BhUyO/cysPiNia6nka2H9YUvLZH3w ioIM1xXvybyrP8hOCHPJNyWZkVIeW9lQvuU/HuGYJdoP3MbRPuwAloTM3qzWhQwqX7nO HkdryPCCcrP/ucmX2xXP73FK6ExXkzE8sdxSXVOc2Nt3nxZ8WgNw/UfcSEoYYEiEW+a/ wdvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=hxshDYUQinqZLqwCYxTrVhfHSHwlIgcN0cuJPsf+c+A=; b=DtcptGJXnLc867q2x2XD8dscGJn4s803ENe1/42Lh3YmTvV4gr32UR6NEH44rqbhJ7 ld58abOgothggnwZCCyNAkO/eoeBMmD+sLw0EfuXKQbNHNmCwsVihllopVUuIeG7fspW v8XUvV75paN3O1QSBpUwfnjmCuAHaTQBsWvC3mXcDG5XcS5Hx93Yc8JRXKeuJieyET4n 4f2eRBxkIW94StYbrYN3VaJlT/F1SNRaXHYj0g165o4WXdcd59V8OJCvr8zNOHd9Uq2N yCoIGVJprpvt355t/NlahFWu0+MuTdmDkNzahDCyrsw0/0f0rwFYdEXhBYbXlvfaM2ji LdxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="RRQwkh/Z"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u133si5996353oib.138.2020.04.04.19.47.48; Sat, 04 Apr 2020 19:48:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="RRQwkh/Z"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726332AbgDECmw (ORCPT + 99 others); Sat, 4 Apr 2020 22:42:52 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:45523 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726057AbgDECmv (ORCPT ); Sat, 4 Apr 2020 22:42:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586054569; 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=hxshDYUQinqZLqwCYxTrVhfHSHwlIgcN0cuJPsf+c+A=; b=RRQwkh/Zajyb1zukSKnzcBo6NWW6desU2KJDwbmOXa8QbVPShm4+ELMzWy468Pr7CYBgJQ evBkYcuuw5QmDyNH3grWN9vbPNa6iBwrYcKAvmGHpAt6duBKyh0/aUvVjEKc4E29q+9wOT wRsrI1wOi/HGCVYcYXYjDnGRTORISZ8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-FfA-z2IZPp-uEjKdsZ7byQ-1; Sat, 04 Apr 2020 22:42:45 -0400 X-MC-Unique: FfA-z2IZPp-uEjKdsZ7byQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E35CF1007269; Sun, 5 Apr 2020 02:42:43 +0000 (UTC) Received: from llong.remote.csb (ovpn-112-153.rdu2.redhat.com [10.10.112.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 072229A260; Sun, 5 Apr 2020 02:42:42 +0000 (UTC) Subject: Re: [GIT PULL] Please pull proc and exec work for 5.7-rc1 To: Linus Torvalds Cc: "Eric W. Biederman" , Ingo Molnar , Will Deacon , Bernd Edlinger , Linux Kernel Mailing List , Alexey Gladkov References: <87blobnq02.fsf@x220.int.ebiederm.org> <87lfnda3w3.fsf@x220.int.ebiederm.org> <328f5ad3-f8b3-09b9-f2f7-b6dae0137542@redhat.com> <86aa9fc6-6ac9-a0c2-3e1d-a602ef16d873@redhat.com> <5c04cc6d-ec44-b840-071d-248ac81a0f91@redhat.com> From: Waiman Long Organization: Red Hat Message-ID: <9876d04e-32c9-dcaa-545a-bfecbf07ea74@redhat.com> Date: Sat, 4 Apr 2020 22:42:42 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/3/20 10:28 PM, Linus Torvalds wrote: > On Fri, Apr 3, 2020 at 7:02 PM Waiman Long wrote: >> So in term of priority, my current thinking is >> >> upgrading unfair reader > unfair reader > reader/writer >> >> A higher priority locker will block other lockers from acquiring the lock. > An alternative option might be to have readers normally be 100% normal > (ie with fairness wrt writers), and not really introduce any special > "unfair reader" lock. A regular down_read() caller will be handled normally. > Instead, all the unfairness would come into play only when the special > case - execve() - does it's special "lock for reading with intent to > upgrade". > > But when it enters that kind of "intent to upgrade" lock state, it > would not only block all subsequent writers, it would also guarantee > that all other readers can continue to go). Yes, that shouldn't be hard to do. If that is what is required, we may only need a special upgrade function to drain the OSQ and then wake up all the readers in the wait queue. I will add a flags argument to that special upgrade function so that we may be able to select different behavior in the future. The regular down_read_interruptible() can be used unless we want to designate only some readers are allowed to do upgrade by calling a special down_read() function. > > So then the new rwsem operations would be > > - read_with_write_intent_lock_interruptible() > > This is the beginning of "execve()", and waits for all writers to > exit, and puts the lock into "all readers can go" mode. > > You could think of it as a "I'm queuing myself for a write lock, > but I'm allowing readers to go ahead" state. > > - read_lock_to_write_upgrade() > > This is the "now this turns into a regular write lock". It needs to > wait for all other readers to exit, of course. > > - read_with_write_intent_unlock() > > This is the "I'm unqueuing myself, I aborted and will not become a > write lock after all" operation. > > NOTE! In this model, there may be multiple threads that do that > initial queuing thing. We only guarantee that only one of them will > get to the actual write lock stage, and the others will abort before > that happens. > > If that is a more natural state machine, then that should work fine > too. And it has some advantages, in that it keeps the readers normally > fair, and only turns them unfair when we get to that special > read-for-write stage. > > But whatever it most natural for the rwsem code. Entirely up to you. To be symmetric with the existing downgrade_write() function, I will choose the name upgrade_read() for the upgrade function. Will that work for you? Cheers, Longman