Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp71373pxb; Mon, 2 Nov 2020 14:21:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsuQokW7Ri0mr7/84ncVy2Z4AwXsJ4dU0MZxZXS9H5Cuy/ek6SX7tB0zSluoRXatz8+W4F X-Received: by 2002:a50:99cd:: with SMTP id n13mr18884192edb.10.1604355712955; Mon, 02 Nov 2020 14:21:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604355712; cv=none; d=google.com; s=arc-20160816; b=PKGQT7YEwDY9OwscdvH8c7aFfyJhptcFjZEHCVPRQ0maHOR5vw06J6Xf7mEVzmLApj tANUJw7uh/NyrxuoVGT/1xTZ7fHfUyBTRUm9Bwr2F18tJ4vi/YasGtbCZIdIEbdw5Cxo nPNwEEh9d+xATHTlzWYaUr7YjIyXkUJSCuwen/wZPsD0XA/VEjhJdaz+ltiJI0W8fRSp o0YfXH37Y1i7rLtPCrz9zTFe4EFYFaF3Blqqm97WzJcIgObdruqyktx1EvaN9W86J7nP 0uZ9WwhOEOU3xeO9bYn/AeXPilNH+9HSBGJU84YMA+qH1eaN9xNf/dTGTc6zD4L2dyx4 9T4Q== 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 :message-id:subject:cc:to:from:dkim-signature:dkim-signature:date; bh=gqiPjScE5SdOJ0m0YaDRtOtnRuC/cXWpfBGliTbmIWA=; b=QQYpmWMBrd1HeDPT3WrIQwufdId6P+05T/Kya/UhAxupFfX+nMGAYd3vvKeXydjEZV ksl+gfbJIrXbPViXlYLC8OuRq6M9NtvltReZroF85Tqq9BT0dV/ax5uXxcqqxLlxZFlu MIAyle44Rs3FqndJSQpXyJk2cTCTJysWSTyNOPPXhd2DxivqB/XYr+2EM+wlVGtKsN4O bj6K9wUOLjKL+5NIbBo9/DZxD5T8vf3CvoCMY1NRceAfgVfOQjhrR0Cy/zP+zd0CrzkA j1WJL/1UEGK1KbHmmQ44Fbe14NgXSXn+k+lGt/cMREeeVJ7B9LNQC/ciD4l/40VUBiBW Q4+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=aWf+gXTC; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=93ql7T2Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p6si12459825edd.206.2020.11.02.14.21.28; Mon, 02 Nov 2020 14:21:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=aWf+gXTC; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=93ql7T2Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725953AbgKBWTy (ORCPT + 99 others); Mon, 2 Nov 2020 17:19:54 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:33452 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725785AbgKBWTx (ORCPT ); Mon, 2 Nov 2020 17:19:53 -0500 Date: Mon, 2 Nov 2020 23:19:45 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1604355592; 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: in-reply-to:in-reply-to; bh=gqiPjScE5SdOJ0m0YaDRtOtnRuC/cXWpfBGliTbmIWA=; b=aWf+gXTCp80n+HKo7bnq7KVcNRhJg5jV6Mn1jzD6rqAOFg4jfeamDbshYhRaQJrqWA1Nfe +yw6XD2+GFvlbM/Yo2NyPo0latCJPJhPvdSn070cbBTvk8b/HNr5Tpnw8cHoorC8lIXnSM 8cD8TPHyEMjmGPSJneV0F408rQOvIAgjsDBv5eYE8omhA2mtfxTh8s9esxZ2U8zCXCdNmi l+5BHuHVSA2FFHc8BM7mC/op3uxMO9WoTeTOJ4zeVkmssqIbldJFKgfBJiK1OfOLhd7Onu j//iNS947DFS2ogjviPGyWkNjkjvy93qCA0nQRdThDCbJCjKEMu1gBUsmr+fTQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1604355592; 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: in-reply-to:in-reply-to; bh=gqiPjScE5SdOJ0m0YaDRtOtnRuC/cXWpfBGliTbmIWA=; b=93ql7T2QRhClLbpJIwM7Al1jkiMyWdZWc/BTBv31stUKAlEBHKpomzkxdb9PPsxAQ3Yk54 1oK4EX69XnwrB9CA== From: "Ahmed S. Darwish" To: Jason Gunthorpe Cc: linux-kernel@vger.kernel.org, Peter Xu , Linus Torvalds , Andrea Arcangeli , Andrew Morton , "Aneesh Kumar K.V" , Christoph Hellwig , Hugh Dickins , Jan Kara , Jann Horn , John Hubbard , Kirill Shutemov , Kirill Tkhai , Leon Romanovsky , Linux-MM , Michal Hocko , Oleg Nesterov , Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner , Sebastian Siewior Subject: Re: [PATCH v2 0/2] Add a seqcount between gup_fast and copy_page_range() Message-ID: <20201102221945.GA48454@lx-t490> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0-v2-dfe9ecdb6c74+2066-gup_fork_jgg@nvidia.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Jason, Thanks for keeping me in the loop on this. I've also added the locking maintainers in Cc. IMHO there are some seqlock.h API violations in this series, and they should have the final say on this. On Fri, Oct 30, 2020 at 11:46:19AM -0300, Jason Gunthorpe wrote: > > As discussed and suggested by Linus use a seqcount to close the small race > between gup_fast and copy_page_range(). > > Unfortunately the good suggestion to just use write_seqcount_begin() blows > up lockdep immediately due to the (new?) requirement that the write side > of seqcount be in a preempt disabled region. Disabling preemption for seqcount_t write-side critical sections was never a new requirement. It has always been this way, for the reasons explained at Documentation/locking/seqlock.rst, "Introduction" section. The recent seqcount_t changes did not mandate any new rules. This was done explicitly, and on-purpose, not to break any of the *large* set of existing seqcount_t call sites. It added multiple lockdep asserts though, to catch a number of (already) buggy users, and they were fixed beforehand. It seems you have a special case here, so I'll continue discussing this at patch #2 where the code resides. Just wanted to answer the "(new?)" part above. > For this application it does > not seem like a good idea, nor is it necessary as we don't spin on retry. > This is solved by being the first place to use raw_write_seqcount_t_begin() > Regardless of this series write side preemptibility requirements, the "_write_seqcount_*t*_()" interfaces are internal to seqlock.h and should _never_ be used outside of it. For plain seqcount_t, raw_write_seqcount_begin() is equivalent to raw_write_seqcount_*t*_begin() anyway, and should already satisfy your needs. /me jumps to patch #2 now... Thanks, -- Ahmed S. Darwish Linutronix GmbH