Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2824022imm; Fri, 24 Aug 2018 06:05:19 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda56BrbheEWB2hxElUtBFjzChUXa/CdxWu8Kpxe2dPh4hgwQh8KHt/6yj3PV5WF/lWV+T5Y X-Received: by 2002:a63:1a25:: with SMTP id a37-v6mr1672364pga.446.1535115919483; Fri, 24 Aug 2018 06:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535115919; cv=none; d=google.com; s=arc-20160816; b=rvxJuNP1P/UvBZLV1WMhqQ6gM4mDWZBdFAtPhiMF1SRRoa9kOvK+9Nmy8wyD4PHRPR wXJie/W9t1UXMQSBDF5OSlGCyYqP6OWwA0a9i6PbitnpmkmNAb2koVdFrRMk3LIogfBt zxYYLXRJZurf40WNnuoRJ51cUvlT6tnzWFwoF+npVlRv2edtGqCkKgoSC+euLezQk1qa f6gEG7Bbz6o+NlzOMt9WQvjGpOl8ZI+RkB5QVU4r1A6sF0J+/jasuQTCg4sipr856f8C 7J1IxPIi0oj3Z9JiMc7VVv43clxG8U30d5Wh7xQ9hUUoxSJo+5rYxvR7bEPyR+4g8LE2 cHNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Gki7yD0W2EkZPsA/m3d9Ye1JEAz11KNLZIZ+8/Qz0h0=; b=YDaRavN9kQttb9w0J0K6Dl8v6//wEF0++8fSjKh7ghPh7ugk81C/tuHEhxF6hADkyx PZ+ZMwWwVd3nIqeCx4CxDbfy7NdhZfEeqcmv+9OK9IkAYRR2R0XSJ2EZEpfFtLArpr0y 37t+Y28s+t7XuX/YdZ6ouysVfcF8NYxzcACmq9id6C2fabqB1Tre7JNMFpQMelFD9Ed6 4nOfu7KuAI+u4pGUhD7i6jiqPF6jQOJe6nYD/8q0W0O3IzkkfsDLACpn8xE9Js+pv10o Uxx6Pr7QDPDXcWb1zI6IMLWtkxVsDe9ZkUzbrJFwa+EenZYiiUMuKWeOCBR9nuOwSEXq awlA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3-v6si6626266pld.281.2018.08.24.06.05.03; Fri, 24 Aug 2018 06:05:19 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727634AbeHXQhy (ORCPT + 99 others); Fri, 24 Aug 2018 12:37:54 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:56408 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726752AbeHXQhy (ORCPT ); Fri, 24 Aug 2018 12:37:54 -0400 Received: from fsav404.sakura.ne.jp (fsav404.sakura.ne.jp [133.242.250.103]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w7OD2TF0031188; Fri, 24 Aug 2018 22:02:29 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav404.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav404.sakura.ne.jp); Fri, 24 Aug 2018 22:02:29 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav404.sakura.ne.jp) Received: from [192.168.1.8] (softbank060157066051.bbtec.net [60.157.66.51]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w7OD2OEO031141 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 24 Aug 2018 22:02:29 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [PATCH] mm, oom: distinguish blockable mode for mmu notifiers To: Michal Hocko , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= Cc: Andrew Morton , LKML , linux-mm@kvack.org, "David (ChunMing) Zhou" , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , 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, =?UTF-8?Q?Christian_K=c3=b6nig?= , David Rientjes , Leon Romanovsky References: <20180716115058.5559-1-mhocko@kernel.org> <8cbfb09f-0c5a-8d43-1f5e-f3ff7612e289@I-love.SAKURA.ne.jp> <20180824113629.GI29735@dhcp22.suse.cz> From: Tetsuo Handa Message-ID: <103b1b33-1a1d-27a1-dcf8-5c8ad60056a6@i-love.sakura.ne.jp> Date: Fri, 24 Aug 2018 22:02:23 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180824113629.GI29735@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/08/24 20:36, Michal Hocko wrote: >> 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. > That is More worrisome part in that patch is that I don't know whether using trylock if blockable == false at entry is really sufficient. . Since those two calls should pair, I think that we need to determine whether we need to return -EAGAIN at start call by evaluating both calls. Like mn_invl_range_start() involves schedule_delayed_work() which could be blocked on memory allocation under OOM situation, I worry that (currently out-of-tree) users of this API are involving work / recursion. And hmm_release() says that /* * Drop mirrors_sem so callback can wait on any pending * work that might itself trigger mmu_notifier callback * and thus would deadlock with us. */ and keeps "all operations protected by hmm->mirrors_sem held for write are atomic". This suggests that "some operations protected by hmm->mirrors_sem held for read will sleep (and in the worst case involves memory allocation dependency)".