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 5186DCD128A for ; Sun, 7 Apr 2024 19:20:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6868D6B0083; Sun, 7 Apr 2024 15:20:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6364B6B0085; Sun, 7 Apr 2024 15:20:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D6546B0087; Sun, 7 Apr 2024 15:20:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 318F56B0083 for ; Sun, 7 Apr 2024 15:20:07 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BB0D91C0570 for ; Sun, 7 Apr 2024 19:20:06 +0000 (UTC) X-FDA: 81983701212.30.E05FD65 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 2449C4000B for ; Sun, 7 Apr 2024 19:20:02 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=R6JHgqDq; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712517604; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=epmQzRcGvXH7QxC5v7WEbN06GWyO/3oH4p1c8L2F2xA=; b=EZRWNpVuCU48PhjgkSimDHQOQj766ooyLuzi4lDY4z/1xhPl29aMY10TgDPjIJiX2wS5qg MyblUqCCxtdl9Zv7oTmCq5pPZxYNefkVwbF3ZWt+kUmAwUSAhR6iVBUYJr6tYMGPeHdfu5 Ig93pkcU7AV78twEo1U21DHkaifcyyM= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=R6JHgqDq; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712517604; a=rsa-sha256; cv=none; b=GG7NpHkVuk5o1/IyS4kYSC9dXkgAdLiEQLaR24H+xdI7uBr9vEYL0O/TIQN0/t8Dmtc7dY 2ZZZh6U4vwqZNp8WTTJZRk9aGEjBMeB1MceNE+i0CJhSecVwqlE/f80c43JEKx9GeWtVQh n2fJic3R2jmq6/Kq5t2+baKxwgup6BU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712517602; 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=epmQzRcGvXH7QxC5v7WEbN06GWyO/3oH4p1c8L2F2xA=; b=R6JHgqDq3USzylmeiHCrkoMAZ9hFrLLqUW2KgOGi9lYnVCNuHlfKZP+vqTnx0B9d7gYwot ynCa2ALQnTu69hO5/WnKm/OUmI7IqFkiq9o11QG78BCFgxX6jkJ5rAOxbq0iV60HrGr84E ygH5imQGKm+A34Psa7AC0P86/qk76Y0= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-321-8UVJUF8SPz-XLlcM9mb97A-1; Sun, 07 Apr 2024 15:20:00 -0400 X-MC-Unique: 8UVJUF8SPz-XLlcM9mb97A-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6993921ae18so3430076d6.0 for ; Sun, 07 Apr 2024 12:20:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712517599; x=1713122399; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=epmQzRcGvXH7QxC5v7WEbN06GWyO/3oH4p1c8L2F2xA=; b=pokv0M4Tpgzc9KtBsMceo72PlVvHb3pRKxW9t53fKFhEgNcT7TeNvLLC+Ze1R/4roZ HM9h76bia+rtGg6l1ZYJo8E5XrNPVIop5VydpUB0UFAdOC+7Bw7f1LCPA28wgLzJAteE ucS8F6K0/dc75B0bLE1Nh7znqEJ36CaZRfapVOQHxhOaLk++xaXdqhUj/zm5ZIaxKnaC DNtgdktdugnYqpll/jMyYr/I+8OloAYdMmY7SX6gEda3wtYEmm2GMEWqgNrDT59jqBC4 ARL05bfrh91Uq2XGchJo2vRvaV65Nksi24UnYXm+CqY1C/WJYxc+66/cBWUkoIwtvXWN ip5g== X-Forwarded-Encrypted: i=1; AJvYcCWCFgZUjk4hBpfTI1J53lAjgbM6CQskzmm5QvnnMAstI1qOiKVWVl2t2/rhL71OQFp5+RmjbAJR0U5fg+XrqsVGav0= X-Gm-Message-State: AOJu0Yxlpol9L2LW4x8My/UUGe1zh7lwAIlm/csgZkrIkgZuoCdSEy0h 7NpCll82P9brBhL+txM69tHk9B6LRqTrUMSIrlAl9/bdD7MSNSwGAp4unAaz1acux1qvwD9Zk67 6gAHcyBcJZMrP0vzDxvPNaPXn50PtRNCVKJpCc6Uh5kWEk1NO X-Received: by 2002:a05:6214:2408:b0:699:2d88:744f with SMTP id fv8-20020a056214240800b006992d88744fmr7791721qvb.4.1712517599501; Sun, 07 Apr 2024 12:19:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdyfcCTiDHVrnBYdH/QV6bU53cJSUCzy2yWOpLwTRXIDtNac8PNjf55b5kNOa6A1BTkng8Qg== X-Received: by 2002:a05:6214:2408:b0:699:2d88:744f with SMTP id fv8-20020a056214240800b006992d88744fmr7791699qvb.4.1712517598978; Sun, 07 Apr 2024 12:19:58 -0700 (PDT) Received: from x1n ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id do18-20020a056214097200b0069942d4cc06sm2111164qvb.115.2024.04.07.12.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 12:19:58 -0700 (PDT) Date: Sun, 7 Apr 2024 15:19:57 -0400 From: Peter Xu To: Oscar Salvador Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Miaohe Lin , David Hildenbrand , stable@vger.kernel.org, Tony Luck , Naoya Horiguchi Subject: Re: [PATCH] mm,swapops: Update check in is_pfn_swap_entry for hwpoison entries Message-ID: References: <20240407130537.16977-1-osalvador@suse.de> 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-Queue-Id: 2449C4000B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: r83ex7xui1cf4zgh3mbxke4i3j6quepy X-HE-Tag: 1712517602-592329 X-HE-Meta: U2FsdGVkX18jWz8+IW3fMLn6B+5/9EP05iThpPlJ63sb/XsP+u7p9hYIzT+gSQLWjFfpDmDUf8Xao8GKHo+NElp8sSM+vtybDujfIm3wfY8NVpzpZIGpWjwo5TDNWESuY8b8Dia99JwZR2lLKMRQKkPNgPdUE6L5DecP9wZR9i9ut7dh9gZEsjSZQe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Od7ujozogqM5Tp7HjnJZP+gKQQ8pKwljznAbVZl2NOJ+/+gfzuOsKF81ojOG/8YH22vU2XnDxJ/PbY+2z76Mx0/4gPRqrCzgnwGhg78HeiZPZQi3nYfXCMIsObzO9trwvnRfqx7jS10dPM8rqE3JIR8HxiAdSc2VTrOsa4/z0xlQwjp+JRLxQAai9PFHICcduwvrAXZazSkzxoUgj8OFq5F5CPeDJt4ifpcvinFs6hYjAFhVIp+DcXdH3TVO0Y8GE9L8= 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: List-Subscribe: List-Unsubscribe: On Sun, Apr 07, 2024 at 03:56:17PM +0200, Oscar Salvador wrote: > On Sun, Apr 07, 2024 at 03:05:37PM +0200, Oscar Salvador wrote: > > Tony reported that the Machine check recovery was broken in v6.9-rc1, > > as he was hitting a VM_BUG_ON when injecting uncorrectable memory errors > > to DRAM. > > After some more digging and debugging on his side, he realized that this > > went back to v6.1, with the introduction of 'commit 0d206b5d2e0d ("mm/swap: add > > swp_offset_pfn() to fetch PFN from swap entry")'. > > That commit, among other things, introduced swp_offset_pfn(), replacing > > hwpoison_entry_to_pfn() in its favour. > > > > The patch also introduced a VM_BUG_ON() check for is_pfn_swap_entry(), > > but is_pfn_swap_entry() never got updated to cover hwpoison entries, which > > means that we would hit the VM_BUG_ON whenever we would call > > swp_offset_pfn() for such entries on environments with CONFIG_DEBUG_VM set. > > Fix this by updating the check to cover hwpoison entries as well, and update > > the comment while we are it. > > > > Reported-by: Tony Luck > > Closes: https://lore.kernel.org/all/Zg8kLSl2yAlA3o5D@agluck-desk3/ > > Tested-by: Tony Luck > > Fixes: 0d206b5d2e0d ("mm/swap: add swp_offset_pfn() to fetch PFN from swap entry") Totally unexpected, as this commit even removed hwpoison_entry_to_pfn(). Obviously even until now I assumed hwpoison is accounted as pfn swap entry but it's just missing.. Since this commit didn't really change is_pfn_swap_entry() itself, I was thinking maybe an older fix tag would apply, but then I noticed the old code indeed should work well even if hwpoison entry is missing. For example, it's a grey area on whether a hwpoisoned page should be accounted in smaps. So I think the Fixes tag is correct, and thanks for fixing this. Reviewed-by: Peter Xu > > Cc: # 6.1.x > > I think I need to clarify why the stable. > > It is my understanding that some distros ship their kernel with > CONFIG_DEBUG_VM set by default (I think Fedora comes to my mind?). > I am fine with backing down if people think that this is an > overreaction. Fedora stopped having DEBUG_VM for some time, but not sure about when it's still in the 6.1 trees. It looks like cc stable is still reasonable from that regard. A side note is that when I'm looking at this, I went back and see why in some cases we need the pfn maintained for the poisoned, then I saw the only user is check_hwpoisoned_entry() who wants to do fast kills in some contexts and that includes a double check on the pfns in a poisoned entry. Then afaict this path is just too rarely used and buggy. A few things we may need fixing, maybe someone in the loop would have time to have a look: - check_hwpoisoned_entry() - pte_none check is missing - all the rest swap types are missing (e.g., we want to kill the proc too if the page is during migration) - check_hwpoisoned_pmd_entry() - need similar care like above (pmd_none is covered not others) I copied Naoya too. Thanks, -- Peter Xu