Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp144601imp; Wed, 20 Feb 2019 16:16:49 -0800 (PST) X-Google-Smtp-Source: AHgI3IbMq7V+iicjBuyAp0WutWRk/HpyxJwmtEWZDaOI9rZyNuYNASDsFZp7MeR52uXWHDNzDKOD X-Received: by 2002:a63:2682:: with SMTP id m124mr30316247pgm.35.1550708209771; Wed, 20 Feb 2019 16:16:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550708209; cv=none; d=google.com; s=arc-20160816; b=Mnu74KMfMKmKQDOaSNp2KNbPmEXqflZ15SD80rj0EPQKBPshdhqQipTkqK/tCy11ou 88G9sP7mkVETmwu4XNECDbkp+w300VUHiFJCqZAhxUNqMo2boRa28VVHm+PLaFM07CSr kUUTHrejQBG8EcFqs0dqNxT4ws002ghsmKCHnEbdagLPd5aPq85mCemUYzYO48BXXnD/ wHYSag8ijH6+enqQd0FrojQQ15PtF+fY68SzAmYzV5q20BX4WBRKpQXQFH56PeH+zwbj 0+2cgti7SwqowmE+Sf30Jpakjg6+oaKdG0nWP0Yycpp87dhIqELEgyGAxcPNy/qnpgVh CKzw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=ZLL1n403Rasb5zF0daZZEyDJvNxP46Um6LbxkczYVNU=; b=fssMMW1fk7mrpZIfWO3A7Qnfv/sKGX+NUYCffT5yxzMfTw+vc/OvUIc0EAtOChTA0f KBDbq0un3GwbW9cJQmqbjvYfWEQ+Siy0a1L8UsSHBpi2/Eqg5wv9jIhZgvbdwL1CImoI p7HN+iM3l8OHdGawWwPFl5lmEIiTmZW/WDP51sI1WeswfJiriK4/PWmkSyD1po8tUEVB +sj4d0OrWQEEZDzMDzwFWtMR7Z2u+ew7N04e6dinY4Hh9+Gx+Gb+InGMY5YVJgLaUj8Y UPGLrHrVrlHmru9flyqGF0/hu2QbesrH+K3TvOCqU5AVd1qzu0EbBW0EWhuEDQ2jgYvK /EWA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2si3734101plo.212.2019.02.20.16.16.31; Wed, 20 Feb 2019 16:16:49 -0800 (PST) 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726224AbfBUAQB (ORCPT + 99 others); Wed, 20 Feb 2019 19:16:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34860 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbfBUAQB (ORCPT ); Wed, 20 Feb 2019 19:16:01 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 066AAC03BD4B; Thu, 21 Feb 2019 00:16:01 +0000 (UTC) Received: from redhat.com (ovpn-120-249.rdu2.redhat.com [10.10.120.249]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E41B65D9D4; Thu, 21 Feb 2019 00:15:59 +0000 (UTC) Date: Wed, 20 Feb 2019 19:15:57 -0500 From: Jerome Glisse To: John Hubbard Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ralph Campbell , Andrew Morton Subject: Re: [PATCH 01/10] mm/hmm: use reference counting for HMM struct Message-ID: <20190221001557.GA24489@redhat.com> References: <20190129165428.3931-1-jglisse@redhat.com> <20190129165428.3931-2-jglisse@redhat.com> <1373673d-721e-a7a2-166f-244c16f236a3@nvidia.com> <20190220235933.GD11325@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 21 Feb 2019 00:16:01 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 20, 2019 at 04:06:50PM -0800, John Hubbard wrote: > On 2/20/19 3:59 PM, Jerome Glisse wrote: > > On Wed, Feb 20, 2019 at 03:47:50PM -0800, John Hubbard wrote: > > > On 1/29/19 8:54 AM, jglisse@redhat.com wrote: > > > > From: J?r?me Glisse > > > > > > > > Every time i read the code to check that the HMM structure does not > > > > vanish before it should thanks to the many lock protecting its removal > > > > i get a headache. Switch to reference counting instead it is much > > > > easier to follow and harder to break. This also remove some code that > > > > is no longer needed with refcounting. > > > > > > Hi Jerome, > > > > > > That is an excellent idea. Some review comments below: > > > > > > [snip] > > > > > > > static int hmm_invalidate_range_start(struct mmu_notifier *mn, > > > > const struct mmu_notifier_range *range) > > > > { > > > > struct hmm_update update; > > > > - struct hmm *hmm = range->mm->hmm; > > > > + struct hmm *hmm = hmm_get(range->mm); > > > > + int ret; > > > > VM_BUG_ON(!hmm); > > > > + /* Check if hmm_mm_destroy() was call. */ > > > > + if (hmm->mm == NULL) > > > > + return 0; > > > > > > Let's delete that NULL check. It can't provide true protection. If there > > > is a way for that to race, we need to take another look at refcounting. > > > > I will do a patch to delete the NULL check so that it is easier for > > Andrew. No need to respin. > > (Did you miss my request to make hmm_get/hmm_put symmetric, though?) Went over my mail i do not see anything about symmetric, what do you mean ? Cheers, J?r?me