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 6B7CCC433EF for ; Thu, 21 Apr 2022 14:28:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D85B86B0072; Thu, 21 Apr 2022 10:28:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D32456B0073; Thu, 21 Apr 2022 10:28:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFA506B0074; Thu, 21 Apr 2022 10:28:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id B13C16B0072 for ; Thu, 21 Apr 2022 10:28:51 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 76744231E3 for ; Thu, 21 Apr 2022 14:28:51 +0000 (UTC) X-FDA: 79381117662.13.0FEB5FD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id DCED720018 for ; Thu, 21 Apr 2022 14:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650551330; 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=wygw0NEtPf4TediRWceCbgQsFgBpsCEztkqk6rmC+rU=; b=Bj2jGzTASOggeNbJks5du8ChFtX9eAzbWrxH939ViCRDXxJMlMxurER/T39B2CTE2QjkGa 9hudPuh/PCXnhBBaiz4+d4uxCg7HPx33PAPTJvyk8bEGhpVGwr5chO2gNhYKsUtqCqiOeQ AQUe5GkRv8nVkaqwIruNqefGZ0wNJvs= Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-280-F_B9yT8bMemw2JtORXkUOg-1; Thu, 21 Apr 2022 10:28:47 -0400 X-MC-Unique: F_B9yT8bMemw2JtORXkUOg-1 Received: by mail-io1-f71.google.com with SMTP id n9-20020a056602340900b006572c443316so2355782ioz.23 for ; Thu, 21 Apr 2022 07:28:46 -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=wygw0NEtPf4TediRWceCbgQsFgBpsCEztkqk6rmC+rU=; b=6eXU7oELZltTaHx4V1n6kHY1kSEDyv/uEVmM6xMh1rGcKeHE/FyqfehUc3QyHzVKCC aYNi8vKuf2uWXdAZ4LJCdvAgSxNoc4iuRRlsLzpyaDmWtNEhTD7QiV/Nwb8BYilM6dzb INgUpIxXOaEeAvpXDTZPxDK5AALYqsXHGDrEY5fhX0RdxAeskSmKY4/q271Z8ad1G0xI YFDXa14BWNfcEgRRK7D6pNbp66sxD32LpCe/EEtfFttcFWYUo1DwnOdzBuF4e6qqO4pm 4/JhOfIdRk0vm3XIf7Nm4/cG569l+uP0ifuRn5qgCI28U4qs+BsfJXZ17x3eJidjTzfz D0zQ== X-Gm-Message-State: AOAM5339JCTpB7fBUF9b95lfF3SuC83Zm/Idn8AlR0y1BWodvSOuwAEB cdVQZojhGwXJlezI4gu+6Kx5E0cSBUQtYM1AtQrdYZAua1zR7YtWCYNl4zkEWvDnwm60WfhkrXY /LxkKxsySZdY= X-Received: by 2002:a02:7058:0:b0:326:70d9:5917 with SMTP id f85-20020a027058000000b0032670d95917mr12003846jac.254.1650551326245; Thu, 21 Apr 2022 07:28:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa92KTjTpe4VCY6SMwA1NEdHcOfaIh8J/D2S1w9pa/SeRX6hhRfCCy3Mvu+V31RvSiJqqOUA== X-Received: by 2002:a02:7058:0:b0:326:70d9:5917 with SMTP id f85-20020a027058000000b0032670d95917mr12003827jac.254.1650551326023; Thu, 21 Apr 2022 07:28:46 -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 y10-20020a92c74a000000b002caca951762sm12219334ilp.19.2022.04.21.07.28.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 07:28:45 -0700 (PDT) Date: Thu, 21 Apr 2022 10:28:44 -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: <20220421125348.62483-4-linmiaohe@huawei.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: DCED720018 X-Stat-Signature: 59zjz6zjp7dm6bzgfbeuye9dmufawa4t Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Bj2jGzTA; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf03.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-HE-Tag: 1650551328-324564 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 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". > + 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? Thanks, -- Peter Xu