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 8FADCC433EF for ; Fri, 22 Apr 2022 02:53:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E582F6B0072; Thu, 21 Apr 2022 22:53:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE1646B0073; Thu, 21 Apr 2022 22:53:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C32B16B0074; Thu, 21 Apr 2022 22:53:07 -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 AD55B6B0072 for ; Thu, 21 Apr 2022 22:53:07 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5B9B623B5C for ; Fri, 22 Apr 2022 02:53:07 +0000 (UTC) X-FDA: 79382993214.12.8FCA456 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 838E680021 for ; Fri, 22 Apr 2022 02:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650595986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rmnSxVr3m8j430qXjhb6BYHPsWg8vcXZrzP1M7hSHg8=; b=afzqzQixPQuLMAuQAg6TUJdsp0PyietFTyeRarC/14oLUhtCzYW6VZZSxia0fjobehYAib xfWA7lU2DRaVQ+KcnvLE0+Kd1oyASa1LT6uyeEri3iNazlNbH3Z+bbT/WlS4jSlLfSR5Zn XTDPJlmESnrKWvfzlKfB10A77/kmUIE= Received: from mail-il1-f200.google.com (mail-il1-f200.google.com [209.85.166.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-493-M2GYEXohO76FMVswAorBSw-1; Thu, 21 Apr 2022 22:53:05 -0400 X-MC-Unique: M2GYEXohO76FMVswAorBSw-1 Received: by mail-il1-f200.google.com with SMTP id p10-20020a056e02104a00b002caa828f7b1so3669859ilj.7 for ; Thu, 21 Apr 2022 19:53:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rmnSxVr3m8j430qXjhb6BYHPsWg8vcXZrzP1M7hSHg8=; b=QQkOPOTpUdStGV+ASsKD6dzDM0oEl9AeMMbUfpkVOp2v/yLeO1n+t698yq1JXhIgdv 98aGiQrq60Fz/18r1W9PQ6sPgE9ytjBvjcwqO5xCpd4dN/buRaSUOV8D2I8cagaIvj7p TBLXYLb4656fA5P1BekJDHWWn3SWBzNw9mCDH/jMa1CguBItcNYv5a1qYAHRsgAbOpkF hhEcIA1BYKG9sdptEG2IY6gh+QIrOUWi/TbFkotr+D7c3d1s41T17WMLrFaLr9eI9ka/ 2ETPy7II4Y3tsxLfrX0iuoPtO+qqigusvj+6aRA7hv3eo6D28TXQE5ugp7f0WLdvfNzc B3Cg== X-Gm-Message-State: AOAM532cavFHRDKVOQ0EN8tDPpjtP8QVZaL2qNxOXfqkzNQWixFHjD4C BWzZmvZcxvn92mb5+nYPOks1wXWEhxoVngiC1S2YOXn8gw/iqq02ghDAoeDLrAX7FSXEWw20/6p P5e3RD3JbsEA= X-Received: by 2002:a05:6638:2604:b0:32a:9c8d:33b7 with SMTP id m4-20020a056638260400b0032a9c8d33b7mr1188377jat.278.1650595984527; Thu, 21 Apr 2022 19:53:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSG+qHo5InB+v+4x+yjnU8lDzVRD1JosP9MDmN/RlEe3NAJ/TUtmBo6iqp4jvLZWwbd9cjFA== X-Received: by 2002:a05:6638:2604:b0:32a:9c8d:33b7 with SMTP id m4-20020a056638260400b0032a9c8d33b7mr1188363jat.278.1650595984257; Thu, 21 Apr 2022 19:53:04 -0700 (PDT) Received: from xz-m1.local (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id 5-20020a6b1405000000b0065064262ef4sm569903iou.30.2022.04.21.19.53.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 19:53:03 -0700 (PDT) Date: Thu, 21 Apr 2022 22:52:59 -0400 From: Peter Xu To: Miaohe Lin Cc: akpm@linux-foundation.org, willy@infradead.org, vbabka@suse.cz, dhowells@redhat.com, neilb@suse.de, david@redhat.com, apopple@nvidia.com, surenb@google.com, minchan@kernel.org, sfr@canb.auug.org.au, naoya.horiguchi@nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/3] mm/madvise: free hwpoison and swapin error entry in madvise_free_pte_range Message-ID: References: <20220421125348.62483-1-linmiaohe@huawei.com> <20220421125348.62483-4-linmiaohe@huawei.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 838E680021 X-Stat-Signature: payenzo74grj354s4xusaejx7jasz1be Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=afzqzQix; spf=none (imf02.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-HE-Tag: 1650595985-423568 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 Fri, Apr 22, 2022 at 10:47:32AM +0800, Miaohe Lin wrote: > On 2022/4/21 22:28, Peter Xu wrote: > > On Thu, Apr 21, 2022 at 08:53:48PM +0800, Miaohe Lin wrote: > >> Once the MADV_FREE operation has succeeded, callers can expect they might > >> get zero-fill pages if accessing the memory again. Therefore it should be > >> safe to delete the hwpoison entry and swapin error entry. There is no > >> reason to kill the process if it has called MADV_FREE on the range. > >> > >> Suggested-by: Alistair Popple > >> Signed-off-by: Miaohe Lin > >> --- > >> mm/madvise.c | 13 ++++++++----- > >> 1 file changed, 8 insertions(+), 5 deletions(-) > >> > >> diff --git a/mm/madvise.c b/mm/madvise.c > >> index 4d6592488b51..5f4537511532 100644 > >> --- a/mm/madvise.c > >> +++ b/mm/madvise.c > >> @@ -624,11 +624,14 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr, > >> swp_entry_t entry; > >> > >> entry = pte_to_swp_entry(ptent); > >> - if (non_swap_entry(entry)) > >> - continue; > >> - nr_swap--; > >> - free_swap_and_cache(entry); > >> - pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); > > > > Nitpick: IMHO you don't need to invert non_swap_entry() then it'll generate > > a smaller diff, just add the new code above "continue". > > I tried this way, but that lead to long line splitting, so I rewrote the code like this. > If you prefer to just add the new code above "continue", I will do it in the next version. No worry then, feel free to keep it as is. > > > > >> + if (!non_swap_entry(entry)) { > >> + nr_swap--; > >> + free_swap_and_cache(entry); > >> + pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); > >> + } else if (is_hwpoison_entry(entry) || > >> + is_swapin_error_entry(entry)) { > >> + pte_clear_not_present_full(mm, addr, pte, tlb->fullmm); > > > > Since it's been discussed and you're reposting a new version anyway, why > > not start with either reusing hwpoison or pte markers? Or do you think it > > should be for future to drop the new swap entry again? > > > > IMHO if reusing hwpoison markers, there are some places that we need to distinguish them and do > different processing (and maybe also well comment them) which will make code more complicated and > somewhat hard to follow. And the "swapin error marker" here is most straightforward. And If pte markers > will support the "swapin error case" in the future, I think it's fine to change to use it then. > Does this make sense for you? Yeah it's fine. If the pte marker things can finally land as expected, maybe I can try it out as the 2nd user of it. :) -- Peter Xu