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 A66CBC433F5 for ; Mon, 25 Apr 2022 08:01:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 293A88D0015; Mon, 25 Apr 2022 04:01:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 243218D0006; Mon, 25 Apr 2022 04:01:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E4828D0015; Mon, 25 Apr 2022 04:01:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id F2FE88D0006 for ; Mon, 25 Apr 2022 04:01:20 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BD5C328409 for ; Mon, 25 Apr 2022 08:01:20 +0000 (UTC) X-FDA: 79394656320.01.AB949A4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 4EA9440044 for ; Mon, 25 Apr 2022 08:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650873679; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VkFL9MtFyT2jXWP8u3N7pMFr8N/9sIoY1jitbMrwBaU=; b=BBzD9aZi4gO+DpoQRpEJectN2hM5BKLTQNKD5LGtoe1/YvnQV4Lksn1khQAVpSwxZoyTmP gvRWDzFasII9wjHdMl8fEvDYBJbU7Hxq9J6gzc/smPI4ZYQp2QiwDC49Vof1z8O6HmayJi cpHoYC0cP0r3d0x2VB+35u+7erEaFfg= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-22-v8lg2XNyNFKthND6BJAfLw-1; Mon, 25 Apr 2022 04:01:18 -0400 X-MC-Unique: v8lg2XNyNFKthND6BJAfLw-1 Received: by mail-wr1-f70.google.com with SMTP id e21-20020adfa455000000b0020ae075cf35so68404wra.11 for ; Mon, 25 Apr 2022 01:01:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=VkFL9MtFyT2jXWP8u3N7pMFr8N/9sIoY1jitbMrwBaU=; b=VEb5SYuGusQSfj4JsUq8rYi6ujaP2JzqGa05egmlYWIPLMMKbwYYQr/Pm2KWJf/AtZ IyNW0u3ybPOsRCm3nAtnbKdymMaGnGDgwDjzyYkMt9enDq7Z7VT2Ljpp6/lS7VLgvOc/ 6oVVZOn9+DVHfIpReEwvV59jtsrqxl5lo7pb95k/hwMKyf5WUB/1kGwnaE/VPExAH+FE FZ2Q+sTEv4z1EuN6lmZzP17jrSYCVgqdkTNdChiJqnWKIhOkZnLGyO0FqJV0oxFoDR9H tC7GAXMdUbLLtyycPOWxDt7plupeSef4R8XOrUZpRfO7/qn+oaMv6MGyKA7Gg1IGbrcs 5axA== X-Gm-Message-State: AOAM530Gx0l+fwoOi38mdfPd0+PJpFgxCjmFS28G0wY3KyzCDEqF1jeV /7bu5hiqLEqlk5Us/XYdMigl/yRr4ARVQ/loleWgRaQ9lxeFJ9/eQvMvqjhtVV8eX8R/Yo2aKXo jZyRN64ko+JM= X-Received: by 2002:a5d:48cc:0:b0:206:d17:10aa with SMTP id p12-20020a5d48cc000000b002060d1710aamr13450856wrs.460.1650873676998; Mon, 25 Apr 2022 01:01:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3U6o+KLtF6TTm6TP8Ie2A4MlAJBrMQWQjM0y9V7eVJ1bBnn+UdwsTUpos/soo1CkyUGZC7w== X-Received: by 2002:a5d:48cc:0:b0:206:d17:10aa with SMTP id p12-20020a5d48cc000000b002060d1710aamr13450834wrs.460.1650873676659; Mon, 25 Apr 2022 01:01:16 -0700 (PDT) Received: from ?IPV6:2003:cb:c700:fc00:490d:ed6a:8b22:223a? (p200300cbc700fc00490ded6a8b22223a.dip0.t-ipconnect.de. [2003:cb:c700:fc00:490d:ed6a:8b22:223a]) by smtp.gmail.com with ESMTPSA id c13-20020adfa30d000000b0020adc82de11sm1755331wrb.26.2022.04.25.01.01.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Apr 2022 01:01:08 -0700 (PDT) Message-ID: Date: Mon, 25 Apr 2022 10:01:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH v3 1/3] mm/swapfile: unuse_pte can map random data if swap read fails To: "ying.huang@intel.com" , Miaohe Lin , akpm@linux-foundation.org Cc: willy@infradead.org, vbabka@suse.cz, dhowells@redhat.com, neilb@suse.de, apopple@nvidia.com, surenb@google.com, minchan@kernel.org, peterx@redhat.com, sfr@canb.auug.org.au, naoya.horiguchi@nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Tim C Chen References: <20220424091105.48374-1-linmiaohe@huawei.com> <20220424091105.48374-2-linmiaohe@huawei.com> <8aeebc2f0b2a251d3d70402cd0edf063ba911013.camel@intel.com> <6c6694965fa3e6d85d78d56703090f227a55bb83.camel@intel.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <6c6694965fa3e6d85d78d56703090f227a55bb83.camel@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 4EA9440044 X-Stat-Signature: s6wodsyeanyht4o8qjauwdaqzuqgnstb Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BBzD9aZi; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf17.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-Rspam-User: X-HE-Tag: 1650873674-646303 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 25.04.22 09:55, ying.huang@intel.com wrote: > On Mon, 2022-04-25 at 09:49 +0200, David Hildenbrand wrote: >> On 25.04.22 09:41, ying.huang@intel.com wrote: >>> Hi, Miaohe, >>> >>> On Sun, 2022-04-24 at 17:11 +0800, Miaohe Lin wrote: >>>> There is a bug in unuse_pte(): when swap page happens to be unreadable, >>>> page filled with random data is mapped into user address space. In case >>>> of error, a special swap entry indicating swap read fails is set to the >>>> page table. So the swapcache page can be freed and the user won't end up >>>> with a permanently mounted swap because a sector is bad. And if the page >>>> is accessed later, the user process will be killed so that corrupted data >>>> is never consumed. On the other hand, if the page is never accessed, the >>>> user won't even notice it. >>>> >>>> Signed-off-by: Miaohe Lin >>>> Acked-by: David Hildenbrand >>>> --- >>>>  include/linux/swap.h | 7 ++++++- >>>>  include/linux/swapops.h | 10 ++++++++++ >>>>  mm/memory.c | 5 ++++- >>>>  mm/swapfile.c | 11 +++++++++++ >>>>  4 files changed, 31 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/include/linux/swap.h b/include/linux/swap.h >>>> index 5553189d0215..b82c196d8867 100644 >>>> --- a/include/linux/swap.h >>>> +++ b/include/linux/swap.h >>>> @@ -55,6 +55,10 @@ static inline int current_is_kswapd(void) >>>>   * actions on faults. >>>>   */ >>>> >>>> +#define SWP_SWAPIN_ERROR_NUM 1 >>>> +#define SWP_SWAPIN_ERROR (MAX_SWAPFILES + SWP_HWPOISON_NUM + \ >>>> + SWP_MIGRATION_NUM + SWP_DEVICE_NUM + \ >>>> + SWP_PTE_MARKER_NUM) >>>> >>>> >>> >>> It appears wasteful to use another swap device number. >> >> Do we really care? >> >> We currently use 5 bits for swap types, so we have a total of 32. >> >> SWP_HWPOISON_NUM -> 1 >> SWP_MIGRATION_NUM -> 3 >> SWP_PTE_MARKER_NUM -> 1 >> SWP_DEVICE_NUM -> 4 >> SWP_SWAPIN_ERROR_NUM -> 1 >> >> Which would leave us with 32 - 10 = 22 swap devices. IMHO that's plenty >> for real life scenarios. > > Creating multiple swap partitions on one disk can improve the > scalability of swap subsystem, although we usually don't have so many > disks for swap. Exactly, and IMHO if we have 22 or 23 doesn't make a real difference here ... -- Thanks, David / dhildenb