linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jerome Glisse <j.glisse@gmail.com>
To: Girish KS <girishks2000@gmail.com>
Cc: "Jérôme Glisse" <jglisse@redhat.com>,
	"Christophe Harle" <charle@nvidia.com>,
	"Mark Hairgrove" <mhairgrove@nvidia.com>,
	"Dave Airlie" <airlied@redhat.com>,
	"Arvind Gopalakrishnan" <arvindg@nvidia.com>,
	"Jatin Kumar" <jakumar@nvidia.com>,
	joro@8bytes.org, "Greg Stoner" <Greg.Stoner@amd.com>,
	akpm@linux-foundation.org,
	"Cameron Buschardt" <cabuschardt@nvidia.com>,
	"Rik van Riel" <riel@redhat.com>,
	"Paul Blinzer" <Paul.Blinzer@amd.com>,
	"Lucien Dunning" <ldunning@nvidia.com>,
	"Johannes Weiner" <jweiner@redhat.com>,
	"Haggai Eran" <haggaie@mellanox.com>,
	"Michael Mantor" <Michael.Mantor@amd.com>,
	"Laurent Morichetti" <Laurent.Morichetti@amd.com>,
	"Larry Woodman" <lwoodman@redhat.com>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Brendan Conoboy" <blc@redhat.com>,
	"John Bridgman" <John.Bridgman@amd.com>,
	"Subhash Gutti" <sgutti@nvidia.com>,
	"Roland Dreier" <roland@purestorage.com>,
	"Duncan Poole" <dpoole@nvidia.com>,
	linux-mm@kvack.org,
	"Alexander Deucher" <Alexander.Deucher@amd.com>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"Andrea Arcangeli" <aarcange@redhat.com>,
	"Leonid Shamis" <Leonid.Shamis@amd.com>,
	"Sherry Cheung" <SCheung@nvidia.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Shachar Raindel" <raindel@mellanox.com>,
	"Liran Liss" <liranl@mellanox.com>,
	"Ben Sander" <ben.sander@amd.com>,
	"Joe Donohue" <jdonohue@redhat.com>,
	"Mel Gorman" <mgorman@suse.de>, "H. Peter Anvin" <hpa@zytor.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	ks.giri@samsung.com
Subject: Re: [PATCH 05/15] HMM: introduce heterogeneous memory management v4.
Date: Mon, 3 Aug 2015 07:56:44 -0400	[thread overview]
Message-ID: <20150803115643.GA2981@gmail.com> (raw)
In-Reply-To: <CAKrE-Kf6e19-KfUkr9nLV1DFbGQCnzGZ49iEVUbm2LVbHFmLtg@mail.gmail.com>

On Mon, Aug 03, 2015 at 01:20:13PM +0530, Girish KS wrote:
> On 18-Jul-2015 12:47 am, "Jerome Glisse" <jglisse@redhat.com> wrote:
> >

[...]

> > +int hmm_mirror_register(struct hmm_mirror *mirror)
> > +{
> > +       struct mm_struct *mm = current->mm;
> > +       struct hmm *hmm = NULL;
> > +       int ret = 0;
> > +
> > +       /* Sanity checks. */
> > +       BUG_ON(!mirror);
> > +       BUG_ON(!mirror->device);
> > +       BUG_ON(!mm);
> > +
> > +       /*
> > +        * Initialize the mirror struct fields, the mlist init and del
> dance is
> > +        * necessary to make the error path easier for driver and for hmm.
> > +        */
> > +       kref_init(&mirror->kref);
> > +       INIT_HLIST_NODE(&mirror->mlist);
> > +       INIT_LIST_HEAD(&mirror->dlist);
> > +       spin_lock(&mirror->device->lock);
> > +       list_add(&mirror->dlist, &mirror->device->mirrors);
> > +       spin_unlock(&mirror->device->lock);
> > +
> > +       down_write(&mm->mmap_sem);
> > +
> > +       hmm = mm->hmm ? hmm_ref(hmm) : NULL;
> 
> Instead of hmm mm->hmm would be the right param to be passed.  Here even
> though mm->hmm is true hmm_ref returns NULL. Because hmm is not updated
> after initialization in the beginning.

ENOPARSE ? While this can be simplified to hmm = hmm_ref(mm->hmm); I do not
see what you mean. The mm struct might already have a valid hmm field set,
and that valid hmm struct might also already be in the process of being
destroy. So hmm_ref() might either return the same hmm pointer if the hmm
object is not about to be release or NULL. But at this point there is no
certainty on the return value of hmm_ref().

Note that because we have the mmap sem in write mode we know it is safe
to dereference mm->hmm and even to overwrite that field it if it is being
destroy concurently.

Cheers,
Jerome

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2015-08-03 11:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17 18:52 [PATCH 00/15] HMM (Heterogeneous Memory Management) v9 Jérôme Glisse
2015-07-17 18:52 ` [PATCH 01/15] mmu_notifier: add event information to address invalidation v8 Jérôme Glisse
2015-07-17 18:52 ` [PATCH 02/15] mmu_notifier: keep track of active invalidation ranges v4 Jérôme Glisse
2015-07-17 18:52 ` [PATCH 03/15] mmu_notifier: pass page pointer to mmu_notifier_invalidate_page() v2 Jérôme Glisse
2015-07-17 18:52 ` [PATCH 04/15] mmu_notifier: allow range invalidation to exclude a specific mmu_notifier Jérôme Glisse
2015-07-17 18:52 ` [PATCH 05/15] HMM: introduce heterogeneous memory management v4 Jérôme Glisse
2015-08-03  7:50   ` Girish KS
2015-08-03 11:56     ` Jerome Glisse [this message]
2015-07-17 18:52 ` [PATCH 06/15] HMM: add HMM page table v3 Jérôme Glisse
2015-07-17 18:52 ` [PATCH 07/15] HMM: add per mirror page table v4 Jérôme Glisse
2015-07-17 18:52 ` [PATCH 08/15] HMM: add device page fault support v4 Jérôme Glisse
2015-07-17 18:52 ` [PATCH 09/15] HMM: add mm page table iterator helpers Jérôme Glisse
2015-07-17 18:52 ` [PATCH 10/15] HMM: use CPU page table during invalidation Jérôme Glisse
2015-07-17 18:52 ` [PATCH 11/15] HMM: add discard range helper (to clear and free resources for a range) Jérôme Glisse
2015-07-17 18:52 ` [PATCH 12/15] HMM: add dirty range helper (toggle dirty bit inside mirror page table) v2 Jérôme Glisse
2015-07-17 18:52 ` [PATCH 13/15] HMM: DMA map memory on behalf of device driver v2 Jérôme Glisse
2015-07-17 18:52 ` [PATCH 14/15] HMM: add documentation explaining HMM internals and how to use it Jérôme Glisse
2015-07-17 18:52 ` [PATCH 15/15] hmm/dummy: dummy driver for testing and showcasing the HMM API Jérôme Glisse
2015-08-13 13:45   ` Sylvain Jeaugey
2015-08-13 14:14     ` Jerome Glisse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150803115643.GA2981@gmail.com \
    --to=j.glisse@gmail.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Greg.Stoner@amd.com \
    --cc=John.Bridgman@amd.com \
    --cc=Laurent.Morichetti@amd.com \
    --cc=Leonid.Shamis@amd.com \
    --cc=Michael.Mantor@amd.com \
    --cc=Paul.Blinzer@amd.com \
    --cc=SCheung@nvidia.com \
    --cc=aarcange@redhat.com \
    --cc=airlied@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=arvindg@nvidia.com \
    --cc=ben.sander@amd.com \
    --cc=blc@redhat.com \
    --cc=cabuschardt@nvidia.com \
    --cc=charle@nvidia.com \
    --cc=dpoole@nvidia.com \
    --cc=girishks2000@gmail.com \
    --cc=haggaie@mellanox.com \
    --cc=hpa@zytor.com \
    --cc=jakumar@nvidia.com \
    --cc=jdonohue@redhat.com \
    --cc=jglisse@redhat.com \
    --cc=jhubbard@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=jweiner@redhat.com \
    --cc=ks.giri@samsung.com \
    --cc=ldunning@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liranl@mellanox.com \
    --cc=lwoodman@redhat.com \
    --cc=mgorman@suse.de \
    --cc=mhairgrove@nvidia.com \
    --cc=peterz@infradead.org \
    --cc=raindel@mellanox.com \
    --cc=riel@redhat.com \
    --cc=roland@purestorage.com \
    --cc=sgutti@nvidia.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).