linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Liam Howlett <liam.howlett@oracle.com>
Cc: Daniel Latypov <dlatypov@google.com>,
	SeongJae Park <sj@kernel.org>,
	"brendanhiggins@google.com" <brendanhiggins@google.com>,
	"kunit-dev@googlegroups.com" <kunit-dev@googlegroups.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"maple-tree@lists.infradead.org" <maple-tree@lists.infradead.org>,
	"damon@lists.linux.dev" <damon@lists.linux.dev>,
	kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v3 30/48] mm/damon: Stop using vma_mas_store() for maple tree store
Date: Thu, 19 Jan 2023 02:00:50 +0000	[thread overview]
Message-ID: <20230119020050.2156-1-sj@kernel.org> (raw)
In-Reply-To: <20230117224734.c4lo4spezufwsims@revolver>

Hello Daniel and Liam,


Sorry for late reply.

On Tue, 17 Jan 2023 22:47:36 +0000 Liam Howlett <liam.howlett@oracle.com> wrote:

> * Daniel Latypov <dlatypov@google.com> [230117 17:20]:
> > On Tue, Jan 17, 2023 at 11:11 AM SeongJae Park <sj@kernel.org> wrote:
> > >
> > > Cc-ing kunit people.
> > >
> > > Hi Liam,
> > >
> > >
> > > Could we put touching file name on the summary?
> > > E.g., mm/damon/vaddr-test: Stop using ...
> > >
> > > On Tue, 17 Jan 2023 02:34:19 +0000 Liam Howlett <liam.howlett@oracle.com> wrote:
> > >
> > > > From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
> > > >
> > > > Prepare for the removal of the vma_mas_store() function by open coding
> > > > the maple tree store in this test code.  Set the range of the maple
> > > > state and call the store function directly.
> > > >
> > > > Cc: SeongJae Park <sj@kernel.org>
> > > > Cc: damon@lists.linux.dev
> > > > Reported-by: kernel test robot <lkp@intel.com>
> > > > Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> > > > ---
> > > >  mm/damon/vaddr-test.h | 19 +++++++++++++------
> > > >  1 file changed, 13 insertions(+), 6 deletions(-)
> > > >
> > > > diff --git a/mm/damon/vaddr-test.h b/mm/damon/vaddr-test.h
> > > > index bce37c487540..6098933d3272 100644
> > > > --- a/mm/damon/vaddr-test.h
> > > > +++ b/mm/damon/vaddr-test.h
> > > > @@ -14,19 +14,26 @@
> > > >
> > > >  #include <kunit/test.h>
> > > >
> > > > -static void __link_vmas(struct maple_tree *mt, struct vm_area_struct *vmas,
> > > > +static int __link_vmas(struct maple_tree *mt, struct vm_area_struct *vmas,
> > > >                       ssize_t nr_vmas)
> > > >  {
> > > > -     int i;
> > > > +     int i, ret = -ENOMEM;
> > > >       MA_STATE(mas, mt, 0, 0);
> > > >
> > > >       if (!nr_vmas)
> > > > -             return;
> > > > +             return -ENOENT;
> > 
> > We could pass in the `test` object here and give more detailed info, e.g.
> >   (if !nr_vmas)
> >      kunit_skip(test, "...");
> > 
> > And below could be
> > 
> > bool stored_all = false; // instead of ret
> > ...
> > for (...) {
> > 
> > }
> > stored_all = true;
> > 
> > failed:
> >   mas_unlock(&mas);
> >   if (!stored_all) kunit_skip(test, "failed to...");
> > 
> > > >
> > > >       mas_lock(&mas);
> > > > -     for (i = 0; i < nr_vmas; i++)
> > > > -             vma_mas_store(&vmas[i], &mas);
> > > > +     for (i = 0; i < nr_vmas; i++) {
> > > > +             mas_set_range(&mas, vmas[i].vm_start, vmas[i].vm_end - 1);
> > > > +             if (mas_store_gfp(&mas, &vmas[i], GFP_KERNEL))
> > > > +                     goto failed;
> > > > +     }
> > > > +     ret = 0;
> > > > +
> > > > +failed:
> > > >       mas_unlock(&mas);
> > > > +     return ret;
> > > >  }
> > > >
> > > >  /*
> > > > @@ -71,7 +78,7 @@ static void damon_test_three_regions_in_vmas(struct kunit *test)
> > > >       };
> > > >
> > > >       mt_init_flags(&mm.mm_mt, MM_MT_FLAGS);
> > > > -     __link_vmas(&mm.mm_mt, vmas, ARRAY_SIZE(vmas));
> > > > +     KUNIT_EXPECT_EQ(test, __link_vmas(&mm.mm_mt, vmas, ARRAY_SIZE(vmas)), 0);
> > >
> > > In case of the __link_vmas() failure, I think we should skip this test using
> > > 'kunit_skip()', rather marking this test failed.
> > 
> > As noted above, I'd suggest we also pass in the `test` object to
> > __link_vmas() and call kunit_skip() from there.
> 
> My thoughts were if we are testing adding nothing to the list, then
> there is probably a problem with the test and so that should be
> highlighted with a failure.
> 
> I really don't mind either way.

I didn't wrote '__link_vmas()' to test vma manipulation functions it internally
uses, but just to offload test setup for 'damon_test_three_regions_in_vmas()'.
I agree that the detailed failure reason could be helpful for better
understanding as the function can now fail from 'mas_store_gfp()'s memory
allocation failure.

That said, I think we can get the detail from the return value of
'__link_vmas()'. I'm further worrying if passing 'test' object to the function
makes people think the function itself is for testing something inside it.

Also, I don't think the function returning non-error for zero value 'nr_vmas'
as a problem but just expected behavior, as previously commented[1].

So I'd prefer doing kunit_skip() here.

If I'm missing something or wrong, please let me know.

[1] https://lore.kernel.org/damon/20230117191614.116521-1-sj@kernel.org/


Thanks,
SJ


  reply	other threads:[~2023-01-19  2:00 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17  2:34 [PATCH v3 00/48] VMA tree type safety and remove __vma_adjust() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 01/48] maple_tree: Add mas_init() function Liam Howlett
2023-01-17  2:34 ` [PATCH v3 03/48] maple_tree: Reduce user error potential Liam Howlett
2023-01-17  2:34 ` [PATCH v3 04/48] test_maple_tree: Test modifications while iterating Liam Howlett
2023-01-17  2:34 ` [PATCH v3 02/48] maple_tree: Fix potential rcu issue Liam Howlett
2023-01-17  2:34 ` [PATCH v3 06/48] maple_tree: Fix mas_prev() and mas_find() state handling Liam Howlett
2023-01-17  2:34 ` [PATCH v3 05/48] maple_tree: Fix handle of invalidated state in mas_wr_store_setup() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 07/48] mm: Expand vma iterator interface Liam Howlett
2023-01-17  2:34 ` [PATCH v3 09/48] kernel/fork: Convert forking to using the vmi iterator Liam Howlett
2023-01-17  2:34 ` [PATCH v3 08/48] mm/mmap: convert brk to use vma iterator Liam Howlett
2023-01-17  2:34 ` [PATCH v3 12/48] mmap: Change do_mas_munmap and do_mas_aligned_munmap() " Liam Howlett
2023-01-17  2:34 ` [PATCH v3 10/48] mmap: Convert vma_link() " Liam Howlett
2023-01-17  2:34 ` [PATCH v3 11/48] mm/mmap: Remove preallocation from do_mas_align_munmap() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 14/48] mm: Add temporary vma iterator versions of vma_merge(), split_vma(), and __split_vma() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 15/48] ipc/shm: Use the vma iterator for munmap calls Liam Howlett
2023-01-17  2:34 ` [PATCH v3 13/48] mmap: Convert vma_expand() to use vma iterator Liam Howlett
2023-01-17  2:34 ` [PATCH v3 18/48] mlock: Convert mlock to " Liam Howlett
2023-01-17  2:34 ` [PATCH v3 16/48] userfaultfd: Use " Liam Howlett
2023-01-17  2:34 ` [PATCH v3 17/48] mm: Change mprotect_fixup to " Liam Howlett
2023-01-17  2:34 ` [PATCH v3 21/48] task_mmu: Convert " Liam Howlett
2023-01-17  2:34 ` [PATCH v3 19/48] coredump: " Liam Howlett
2023-01-17  2:34 ` [PATCH v3 20/48] mempolicy: " Liam Howlett
2023-01-17  2:34 ` [PATCH v3 22/48] sched: " Liam Howlett
2023-01-17  2:34 ` [PATCH v3 23/48] madvise: Use vmi iterator for __split_vma() and vma_merge() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 24/48] mmap: Pass through vmi iterator to __split_vma() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 25/48] mmap: Use vmi version of vma_merge() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 28/48] nommu: Pass through vma iterator to shrink_vma() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 26/48] mm/mremap: Use vmi version of vma_merge() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 27/48] nommu: Convert nommu to using the vma iterator Liam Howlett
2023-01-17  2:34 ` [PATCH v3 29/48] mm: Switch vma_merge(), split_vma(), and __split_vma to " Liam Howlett
2023-01-17  2:34 ` [PATCH v3 31/48] mmap: Convert __vma_adjust() to use " Liam Howlett
2023-01-17  2:34 ` [PATCH v3 30/48] mm/damon: Stop using vma_mas_store() for maple tree store Liam Howlett
2023-01-17 19:11   ` SeongJae Park
2023-01-17 19:16     ` SeongJae Park
2023-01-17 22:20     ` Daniel Latypov
2023-01-17 22:47       ` Liam Howlett
2023-01-19  2:00         ` SeongJae Park [this message]
2023-01-19 18:55           ` Liam R. Howlett
2023-01-17  2:34 ` [PATCH v3 35/48] mm: Pass vma iterator through to __vma_adjust() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 33/48] madvise: Use split_vma() instead of __split_vma() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 34/48] mm: Remove unnecessary write to vma iterator in __vma_adjust() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 32/48] mm: Pass through vma iterator to __vma_adjust() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 36/48] mm: Add vma iterator to vma_adjust() arguments Liam Howlett
2023-01-17  2:34 ` [PATCH v3 38/48] mm: Change munmap splitting order and move_vma() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 37/48] mmap: Clean up mmap_region() unrolling Liam Howlett
2023-01-17  2:34 ` [PATCH v3 39/48] mm/mmap: move anon_vma setting in __vma_adjust() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 41/48] mm/mmap: Use vma_prepare() and vma_complete() in vma_expand() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 40/48] mm/mmap: Refactor locking out of __vma_adjust() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 42/48] mm/mmap: Introduce init_vma_prep() and init_multi_vma_prep() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 43/48] mm: Don't use __vma_adjust() in __split_vma() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 45/48] mm/mmap: Introduce dup_vma_anon() helper Liam Howlett
2023-01-17  2:34 ` [PATCH v3 44/48] mm/mmap: Don't use __vma_adjust() in shift_arg_pages() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 47/48] mm/mmap: Remove __vma_adjust() Liam Howlett
2023-01-17  2:34 ` [PATCH v3 48/48] vma_merge: Set vma iterator to correct position Liam Howlett
2023-01-17  2:34 ` [PATCH v3 46/48] mm/mmap: Convert do_brk_flags() to use vma_prepare() and vma_complete() Liam Howlett

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=20230119020050.2156-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=brendanhiggins@google.com \
    --cc=damon@lists.linux.dev \
    --cc=dlatypov@google.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=liam.howlett@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=maple-tree@lists.infradead.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