Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2737739imm; Fri, 24 Aug 2018 04:37:52 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda+nPbPS26JHz9dolRBBT9vxa8t0hfKfs7emnDRl2u7nQntEaB31C4WQ3y2aJnIw6Bhnan7 X-Received: by 2002:a17:902:292b:: with SMTP id g40-v6mr1321317plb.223.1535110672179; Fri, 24 Aug 2018 04:37:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535110672; cv=none; d=google.com; s=arc-20160816; b=d9hosBo4qgBYxxqFMuy4HZ7Z2tz0h5ubAU2EHqVc4Q9m3KCwxF0CNBqvhnQ6krBDvd bo9ObWN1l7Q6g6QHboE3qurQzX07PV3AbL3XjNzj/+JuodXdaeAxmNPhQjauZ8IdFvRr AXeOWeryOvKKHosi4exSelcqYggmWG1tQwoq8e1PrIXcjfFnehyVI3WZdR0OlQ3sm98Q OSEUgjYilslzkMxmOhIIKdNMbI+4GpsI4wd+w3UJRdWZPYhBei+1PjMX8RO+aUF6hZSB psgY0Rjis1S9Rur5P81Gds4N6vc6wJK1e24idNiiRJ3VZTbobDPeqpEFpdkANimQE/rQ mTKw== 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:arc-authentication-results; bh=LakK8VmwIoGKIeavCK4Z8pyts8oTHYnKxd4fGVZg37w=; b=zmANb3bM2WbTRqTW5WYlEbL5tyBuMkXLgrfggAImLE5pjYN6/necoVBo1RDHkM2Y3U nfbfmjQhS/hbW2ZMhljePP8dcCZ2A30vmu0TY/ZFldU4vPnHcAtiRKyd/E3tDng78FEJ 3m4gqcADWb6UE2b7tFIJYc5/uO0Ktz5DuQGh4dxEykU6jeOLDu7gxIdFD/gyhIgMsfZK HbVVe+UGrEDhwvShr47drt8ynUx1FfmNTdrjcpCIdOgoaZf0tYtFTJ/2GtqPLt0oFPei oGs7io0kVvN0N1ttTCFZK7WDp8or/q5jDzMDc+UL7TpaU8z6Oh68dezAE89P/R3nQJVI cbvw== 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 h3-v6si7064019pgc.122.2018.08.24.04.37.36; Fri, 24 Aug 2018 04:37:52 -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 S1727705AbeHXPKs (ORCPT + 99 others); Fri, 24 Aug 2018 11:10:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:34460 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726513AbeHXPKs (ORCPT ); Fri, 24 Aug 2018 11:10:48 -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 656F3AC89; Fri, 24 Aug 2018 11:36:30 +0000 (UTC) Date: Fri, 24 Aug 2018 13:36:29 +0200 From: Michal Hocko To: Tetsuo Handa , =?iso-8859-1?B?Suly9G1l?= Glisse Cc: Andrew Morton , LKML , linux-mm@kvack.org, "David (ChunMing) Zhou" , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Alex Deucher , David Airlie , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Doug Ledford , Jason Gunthorpe , Mike Marciniszyn , Dennis Dalessandro , Sudeep Dutt , Ashutosh Dixit , Dimitri Sivanich , Boris Ostrovsky , Juergen Gross , Andrea Arcangeli , Felix Kuehling , kvm@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-rdma@vger.kernel.org, xen-devel@lists.xenproject.org, Christian =?iso-8859-1?Q?K=F6nig?= , David Rientjes , Leon Romanovsky Subject: Re: [PATCH] mm, oom: distinguish blockable mode for mmu notifiers Message-ID: <20180824113629.GI29735@dhcp22.suse.cz> References: <20180716115058.5559-1-mhocko@kernel.org> <8cbfb09f-0c5a-8d43-1f5e-f3ff7612e289@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8cbfb09f-0c5a-8d43-1f5e-f3ff7612e289@I-love.SAKURA.ne.jp> 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 Fri 24-08-18 19:54:19, Tetsuo Handa wrote: [...] > > --- a/mm/hmm.c > > +++ b/mm/hmm.c > > @@ -177,16 +177,19 @@ static void hmm_release(struct mmu_notifier *mn, struct mm_struct *mm) > > up_write(&hmm->mirrors_sem); > > } > > > > -static void hmm_invalidate_range_start(struct mmu_notifier *mn, > > +static int hmm_invalidate_range_start(struct mmu_notifier *mn, > > struct mm_struct *mm, > > unsigned long start, > > - unsigned long end) > > + unsigned long end, > > + bool blockable) > > { > > struct hmm *hmm = mm->hmm; > > > > VM_BUG_ON(!hmm); > > > > atomic_inc(&hmm->sequence); > > + > > + return 0; > > } > > > > static void hmm_invalidate_range_end(struct mmu_notifier *mn, > > This assumes that hmm_invalidate_range_end() does not have memory > allocation dependency. But hmm_invalidate_range() from > hmm_invalidate_range_end() involves > > down_read(&hmm->mirrors_sem); > list_for_each_entry(mirror, &hmm->mirrors, list) > mirror->ops->sync_cpu_device_pagetables(mirror, action, > start, end); > up_read(&hmm->mirrors_sem); > > sequence. What is surprising is that there is no in-tree user who assigns > sync_cpu_device_pagetables field. Yes HMM doesn't have any in tree user yet. > $ grep -Fr sync_cpu_device_pagetables * > Documentation/vm/hmm.rst: /* sync_cpu_device_pagetables() - synchronize page tables > include/linux/hmm.h: * will get callbacks through sync_cpu_device_pagetables() operation (see > include/linux/hmm.h: /* sync_cpu_device_pagetables() - synchronize page tables > include/linux/hmm.h: void (*sync_cpu_device_pagetables)(struct hmm_mirror *mirror, > include/linux/hmm.h: * hmm_mirror_ops.sync_cpu_device_pagetables() callback, so that CPU page > mm/hmm.c: mirror->ops->sync_cpu_device_pagetables(mirror, action, > > That is, this API seems to be currently used by only out-of-tree users. Since > we can't check that nobody has memory allocation dependency, I think that > hmm_invalidate_range_start() should return -EAGAIN if blockable == false for now. The code expects that the invalidate_range_end doesn't block if invalidate_range_start hasn't blocked. That is the reason why the end callback doesn't have blockable parameter. If this doesn't hold then the whole scheme is just fragile because those two calls should pair. -- Michal Hocko SUSE Labs