Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10074815ybi; Wed, 24 Jul 2019 15:28:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNeX4SBtR3qhBvGbJ7M8GibhHWwQP+Ksh3znVP9DGI40wm/gX3d+p7yc4Iv9QhftclDERg X-Received: by 2002:a17:90a:bc0c:: with SMTP id w12mr57490408pjr.111.1564007287579; Wed, 24 Jul 2019 15:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564007287; cv=none; d=google.com; s=arc-20160816; b=gh1FWRmSqtYEQnLo9Z3G5q12ULgGdaHrbj9ta5r9yxROdXqrMSLSmvknUG2t3zmd7U sG7wl6DJQwzN/zIoTw1/fvfEHaOVMdJrkztdE/p115uzt2IY+l0GMXNhDFjGK5p/Jaly UNLaFvy6CMOQ0C7lQ27Xh+eCf6wRMkU0ze0IpSTwFCh3zLVv6EM7dff9QBrh0UJSMwe3 5R/EP2DuaO6ETIpQMtY0Z0ucVvCwj2ZRDOePv3EBKbIFpV4hM3yK8FljLHsAB0Oq93Zh jPqiDRg9MZxdBw/Eu5S6D4mFYp/GiZXk0hIQ0f8GB/bAagBwT2lDOO7dYbKpJVEWE8ZB Wfjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=b0XO25dTeIVLUe5LFpL0rTb2bvBuDnyq2pFxVT/CAhk=; b=a7rfG4wveBl9mQ43wDtjFudHFYc3p0GRz44KThIGaLHUlh3P4iNYdiuT0/pFO9SyCr Krq6DFRZaV1DSS2EdZmG8tFzNm6eXFw+/ZlWXP6g5o5oo8lD78wyTqiY56w2noChrCph y/CQlINapewvedh+ti1e0EfrVoCSQfIiGSw2isg71qxheIloIWhKGTadQyTIivBJcQaS lcAB4X9rhHDd4WcBKRILhjF7e3mOddvwtfAsH9eGvyVzff6WFFh6HXGSWhauOTD5zfGd u2uOfHQZHiExZhDa981Q0tmAVwOYQ02qNwemA6g+OAW7JiDxpKfO9LBcXvTaEUT2Ocz+ mn7A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id br18si15350710pjb.52.2019.07.24.15.27.53; Wed, 24 Jul 2019 15:28:07 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728788AbfGXS7P (ORCPT + 99 others); Wed, 24 Jul 2019 14:59:15 -0400 Received: from mx2.suse.de ([195.135.220.15]:46982 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725883AbfGXS7P (ORCPT ); Wed, 24 Jul 2019 14:59:15 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 170CCADC1; Wed, 24 Jul 2019 18:59:14 +0000 (UTC) Date: Wed, 24 Jul 2019 20:59:10 +0200 From: Michal Hocko To: Jason Gunthorpe Cc: Christoph Hellwig , Ralph Campbell , linux-mm@kvack.org, linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, =?iso-8859-1?B?Suly9G1l?= Glisse , Ben Skeggs Subject: Re: [PATCH] mm/hmm: replace hmm_update with mmu_notifier_range Message-ID: <20190724185910.GF6410@dhcp22.suse.cz> References: <20190723210506.25127-1-rcampbell@nvidia.com> <20190724070553.GA2523@lst.de> <20190724152858.GB28493@ziepe.ca> <20190724175858.GC6410@dhcp22.suse.cz> <20190724180837.GF28493@ziepe.ca> <20190724185617.GE6410@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190724185617.GE6410@dhcp22.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 24-07-19 20:56:17, Michal Hocko wrote: > On Wed 24-07-19 15:08:37, Jason Gunthorpe wrote: > > On Wed, Jul 24, 2019 at 07:58:58PM +0200, Michal Hocko wrote: > [...] > > > Maybe new users have started relying on a new semantic in the meantime, > > > back then, none of the notifier has even started any action in blocking > > > mode on a EAGAIN bailout. Most of them simply did trylock early in the > > > process and bailed out so there was nothing to do for the range_end > > > callback. > > > > Single notifiers are not the problem. I tried to make this clear in > > the commit message, but lets be more explicit. > > > > We have *two* notifiers registered to the mm, A and B: > > > > A invalidate_range_start: (has no blocking) > > spin_lock() > > counter++ > > spin_unlock() > > > > A invalidate_range_end: > > spin_lock() > > counter-- > > spin_unlock() > > > > And this one: > > > > B invalidate_range_start: (has blocking) > > if (!try_mutex_lock()) > > return -EAGAIN; > > counter++ > > mutex_unlock() > > > > B invalidate_range_end: > > spin_lock() > > counter-- > > spin_unlock() > > > > So now the oom path does: > > > > invalidate_range_start_non_blocking: > > for each mn: > > a->invalidate_range_start > > b->invalidate_range_start > > rc = EAGAIN > > > > Now we SKIP A's invalidate_range_end even though A had no idea this > > would happen has state that needs to be unwound. A is broken. > > > > B survived just fine. > > > > A and B *alone* work fine, combined they fail. > > But that requires that they share some state, right? > > > When the commit was landed you can use KVM as an example of A and RDMA > > ODP as an example of B > > Could you point me where those two share the state please? KVM seems to > be using kvm->mmu_notifier_count but I do not know where to look for the > RDMA... Scratch that. ELONGDAY... I can see your point. It is all or nothing that doesn't really work here. Looking back at your patch it seems reasonable but I am not sure what is supposed to be a behavior for notifiers that failed. -- Michal Hocko SUSE Labs