From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B310DC433EF for ; Thu, 28 Apr 2022 22:00:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 278896B0072; Thu, 28 Apr 2022 18:00:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2270C6B0073; Thu, 28 Apr 2022 18:00:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C8C16B0074; Thu, 28 Apr 2022 18:00:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id F2B6D6B0072 for ; Thu, 28 Apr 2022 18:00:23 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D7E65221E5 for ; Thu, 28 Apr 2022 22:00:23 +0000 (UTC) X-FDA: 79407657126.23.691160F Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by imf09.hostedemail.com (Postfix) with ESMTP id 6696C140060 for ; Thu, 28 Apr 2022 22:00:19 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id j4so10955745lfh.8 for ; Thu, 28 Apr 2022 15:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=N6m9krQzXBWKdDV0IW+yPv7DN4a6AnpOmHkd1C0ZeJ4=; b=KhxzhDVXD8ouF5yeuAtX+zZk7YKxGcB0eM7HNpi8Dpf/PZRszmBzfNa9tXROpxv8lX eWEhw+yLjHiLhvwudRQx5XkjB2e+onh2yD+rCEN2lo6qXm0NHtsSx9gXO1ay4Kh0Dvca u1bxCuApWjQSaOO5cOchfZP7pOueLwe7xjK7d8xQrFI4+8oZvELjsCcHTy7qtwfEHq7D YLaTgwmd9Jf03v/IDv6nkPIfnBj1r0ii7oiu28nXZVbas3xEsW7yBvva1RaitwjIznUw VEL13ZpAKiHqI3m8h/+9Z2CbHMG2pcy1Tljf1txI0mLNSbD3DgGf8+RU5q2/hrDzNybn 13IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=N6m9krQzXBWKdDV0IW+yPv7DN4a6AnpOmHkd1C0ZeJ4=; b=m2yOuafmNMJhlWGDjxChf14cAjAKCANfi4i67+lKXprbpaFbGdh7UUOypfg3gSOBun f7Bl781X3z6UY85/aTAEA2XbOEltJhh+WHLkL/meuBry4u0Xqd7UUeFN5u4xN9G8jYfC qLcmrB4NXqNW7MHDVD3yZQbBAylLwFGoSoBEmuaqMKGp1wtVt6IuYrPBrToxk2aruaXr 03sCjeLSPsx93mFS0aX3An3hl2oG36hFS0iyYRruqgkQBEeYFOTDcfu4wg/TbKWGw0db 42tYWT0PvrHlKoBIXppFzPndtJ54PYmK1fhx1nWAzxo99oATgDzLjiRQIueOq0lTMjBJ HhOQ== X-Gm-Message-State: AOAM532yysEiuVSCKt5sOWk9UAvaNylfncZSCjFkOBjJNWMtJmJ/PNcq awsoRzMQSp6Bir5WqQqQSxquXXAwLoL4TfeixuiEkw== X-Google-Smtp-Source: ABdhPJxm6lH8EpjwLWmNz4d2sEA4W/w6NlxrkEgxBsY1VuGJejpL5npoLVsokDLhAiXcvIyERTYEKfblhR9covKp0Tg= X-Received: by 2002:a19:4952:0:b0:472:1056:a93c with SMTP id l18-20020a194952000000b004721056a93cmr12797243lfj.60.1651183221211; Thu, 28 Apr 2022 15:00:21 -0700 (PDT) MIME-Version: 1.0 References: <20220426144412.742113-1-zokeefe@google.com> <20220426144412.742113-5-zokeefe@google.com> In-Reply-To: From: "Zach O'Keefe" Date: Thu, 28 Apr 2022 14:59:44 -0700 Message-ID: Subject: Re: [PATCH v3 04/12] mm/khugepaged: add struct collapse_result To: Peter Xu Cc: Alex Shi , David Hildenbrand , David Rientjes , Matthew Wilcox , Michal Hocko , Pasha Tatashin , SeongJae Park , Song Liu , Vlastimil Babka , Yang Shi , Zi Yan , linux-mm@kvack.org, Andrea Arcangeli , Andrew Morton , Arnd Bergmann , Axel Rasmussen , Chris Kennelly , Chris Zankel , Helge Deller , Hugh Dickins , Ivan Kokshaysky , "James E.J. Bottomley" , Jens Axboe , "Kirill A. Shutemov" , Matt Turner , Max Filippov , Miaohe Lin , Minchan Kim , Patrick Xia , Pavel Begunkov , Thomas Bogendoerfer Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6696C140060 X-Stat-Signature: 1nbyz4q5k1jwmju5eay3zd8ifa9rd1x1 X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=KhxzhDVX; spf=pass (imf09.hostedemail.com: domain of zokeefe@google.com designates 209.85.167.44 as permitted sender) smtp.mailfrom=zokeefe@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1651183219-616623 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Apr 27, 2022 at 1:47 PM Peter Xu wrote: > > On Tue, Apr 26, 2022 at 07:44:04AM -0700, Zach O'Keefe wrote: > > +/* Gather information from one khugepaged_scan_[pmd|file]() request */ > > +struct collapse_result { > > + enum scan_result result; > > + > > + /* Was mmap_lock dropped during request? */ > > + bool dropped_mmap_lock; > > +}; > > IMHO this new dropped_mmap_lock makes things a bit more complicated.. > > To me, the old code actually is easy to read on when the lock is dropped: > > - For file, we always drop it > - For anon, when khugepaged_scan_pmd() returns 1 > > That's fairly clear to me. > Agreed - but I know when I first read the code it wasn't obvious to me what the return value of khugepaged_scan_pmd() was saying. I thought giving it a name ("dropped_mmap_lock") would help future readers. That said, I'm fine reverting this and going back to the old way of things. It's less members crowding struct collapse_control as well. > But I understand what you need, probably the "result" hidden in the old > world but you'd need that for MADV_COLLAPSE? > > I also noticed major chunks of this patch is converting "result = XXX" into > "cr->result = XXX". IMHO that's really not necessary for touching up all > the places around. > > I'm also wondering whether we could simply pass over the result into your > newly introduced collapse_control*. > > In summary, this is what's in my mind.. > > - Add collapse_control.result > - Make sure both khugepaged_scan_file() and khugepaged_scan_pmd() to > simply remember to update cc->result before it returns > > I've attached a pesudo code patch (note! it's pesudo not even compile but > to show what I meant..), so far I don't see a problem with it. > Thanks for going so far as to throw this patch together! I've gone ahead and used it with minimal changes. I agree that it's cleaner now. > -- > Peter Xu