Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9849729ybi; Wed, 24 Jul 2019 11:02:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWIoijhW6FFcBVty4Q/ctVzaYUseAv5QSq4X0yX0CkdY4yvS+SOKCAGCQ4OJLOIdKX86ol X-Received: by 2002:a63:d941:: with SMTP id e1mr49190780pgj.75.1563991356307; Wed, 24 Jul 2019 11:02:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563991356; cv=none; d=google.com; s=arc-20160816; b=cdmoKFmBqsNp20l1sytSyOxLxPj/d94jzQJN+gnZomc1IISSd4f2VBkt9R6ix1r9h7 noIWaIcQKCD6UCeQUuL+7cFfkbsmEHqgR/1CsajW2BJHUoNBmjWkH6RN6ggR0owgv6Fc v0mFLA7a0WGGYFNF52VPtLerIdu19brQQVqUW6uQXWTEBAq0KgfDRwcAbEgT38AoQ93i YEK61PGyceYC2UerCTiXU8jmjfINCv+0xd67tBji5PKaeXoo2EmB55d8IOp/5I5FTxIa PZQh0BwZiaF+LcTKjQyQvfD0ATzKKcWsddGWufpb84Pj26gIj+QuQs2Gc6EcokJNy4sF YEdw== 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=sdGYzOGLozYXl0ObsR0hxWNUtHpzDtIyu41JyTaHejI=; b=h7EAiB84gNw8DIQB/nXe3Y06IoeHBpBcDM3xtEjvIk3LXx1K9IHHEf5139z33p9Umm KXHF0nUp08YaCM4F096Bveh7zaWI4F1tNlFw6wh/PmrqGtA8ZuFLr+dvgkSO5f7MeBIw xsuJErf53U3pzBVtirvK9KlgfdC/rNDD6Do3QVMx93jiMV/KVWUlNNwM48OdXERgYzYl Dgh9dLf3EEqMuCEbRSvLca57q0WagGyVxAJL2bdbV1ONrkZOthifnKxqRCZY28Ixj5r0 s912DwluBurcblLtKdrTlMqE7msq+ctXbZZ7kbWK65AW7P9jiir4ZOjF+ReONx8ixjRk Hjdg== 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 f6si13915093pgc.123.2019.07.24.11.02.22; Wed, 24 Jul 2019 11:02:36 -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 S1726767AbfGXR7B (ORCPT + 99 others); Wed, 24 Jul 2019 13:59:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:33240 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726312AbfGXR7A (ORCPT ); Wed, 24 Jul 2019 13:59:00 -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 4FF3CABD9; Wed, 24 Jul 2019 17:58:59 +0000 (UTC) Date: Wed, 24 Jul 2019 19:58:58 +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: <20190724175858.GC6410@dhcp22.suse.cz> References: <20190723210506.25127-1-rcampbell@nvidia.com> <20190724070553.GA2523@lst.de> <20190724152858.GB28493@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190724152858.GB28493@ziepe.ca> 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 12:28:58, Jason Gunthorpe wrote: > On Wed, Jul 24, 2019 at 09:05:53AM +0200, Christoph Hellwig wrote: > > Looks good: > > > > Reviewed-by: Christoph Hellwig > > > > One comment on a related cleanup: > > > > > list_for_each_entry(mirror, &hmm->mirrors, list) { > > > int rc; > > > > > > - rc = mirror->ops->sync_cpu_device_pagetables(mirror, &update); > > > + rc = mirror->ops->sync_cpu_device_pagetables(mirror, nrange); > > > if (rc) { > > > - if (WARN_ON(update.blockable || rc != -EAGAIN)) > > > + if (WARN_ON(mmu_notifier_range_blockable(nrange) || > > > + rc != -EAGAIN)) > > > continue; > > > ret = -EAGAIN; > > > break; > > > > This magic handling of error seems odd. I think we should merge rc and > > ret into one variable and just break out if any error happens instead > > or claiming in the comments -EAGAIN is the only valid error and then > > ignoring all others here. > > The WARN_ON is enforcing the rules already commented near > mmuu_notifier_ops.invalidate_start - we could break or continue, it > doesn't much matter how to recover from a broken driver, but since we > did the WARN_ON this should sanitize the ret to EAGAIN or 0 > > Humm. Actually having looked this some more, I wonder if this is a > problem: > > I see in __oom_reap_task_mm(): > > if (mmu_notifier_invalidate_range_start_nonblock(&range)) { > tlb_finish_mmu(&tlb, range.start, range.end); > ret = false; > continue; > } > unmap_page_range(&tlb, vma, range.start, range.end, NULL); > mmu_notifier_invalidate_range_end(&range); > > Which looks like it creates an unbalanced start/end pairing if any > start returns EAGAIN? > > This does not seem OK.. Many users require start/end to be paired to > keep track of their internal locking. Ie for instance hmm breaks > because the hmm->notifiers counter becomes unable to get to 0. > > Below is the best idea I've had so far.. > > Michal, what do you think? IIRC we have discussed this with Jerome back then when I've introduced this code and unless I misremember he said the current code was OK. 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. Has this changed? -- Michal Hocko SUSE Labs