From patchwork Mon May 22 07:09:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 13249897 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 8AB25C77B75 for ; Mon, 22 May 2023 07:09:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D177900004; Mon, 22 May 2023 03:09:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 980FF900002; Mon, 22 May 2023 03:09:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86F38900004; Mon, 22 May 2023 03:09:39 -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 73939900002 for ; Mon, 22 May 2023 03:09:39 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3FB301A0501 for ; Mon, 22 May 2023 07:09:39 +0000 (UTC) X-FDA: 80817015678.20.CFA71E8 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf19.hostedemail.com (Postfix) with ESMTP id E721E1A0017 for ; Mon, 22 May 2023 07:09:35 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=a8eO16Pt; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf19.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684739377; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=G1Ak/OnM2wW/X54SOlrTibOwiyYIBpTMQ/6+tPdYmp4=; b=G3xd1UHZx8U4zMySR6aI7Tc4e/WJOmo6nXNsDWiYgyoRYfva9TJx+nYs/kgSsejJCQw68t TCvW9SM1x4BVhSi6HYch6dhgCJXoYZBkA21VQljOqmiVEFTGihi9cqa+fWKb1uYleeHy4X 2txGDhQUFtS36wv0ns4KdlvdNZCHE6A= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=a8eO16Pt; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf19.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684739377; a=rsa-sha256; cv=none; b=b96U7vAIGEmk4bdegdNwGnLZWoKM3XqWzH/anawTHL70bLlECXnB6pk14EWhtN20Gsc/BF KTdvvPM9O0WB89dZrgEIwJjMtxLrsDP4GpVCcI+27Uc2XLtCzlT5/teMi8a841a+fsnjJ7 kAq/nNr4zi6NLTe184zQJqD9/zh63Uw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684739376; x=1716275376; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=na5mcQ5pzQRlV4B5n8k09Kfb5lJnl8hyX0HKXBlJC28=; b=a8eO16PtG6Pkbh8+Dd2oh9UIFcCriaO7And/jj29Pe86JDDQ4pvwWMmP vpUWWmSsNxi1RaoskVaJ+xXaTCMdQvjb67caoLwr26XyYkCBx0C4yW5pp ijZSe5JRh0QwP9cBEQpdqvZB/nuwcvbun4YoXD+7eMDCuzauuca5m6NOC NPQQSzm54g8IDw3DzDmccxsCGdcUQNnki9cQg7HV6dNPuYXP3Uc6HcTh+ nZja5fGkZHLES4M3rPNJEbOAN79a1jkXtF1rwEqLiiAjUUnev03a7odmC UhtaqUxN3hU+EHNShqKyqPy7gEyk/OSzG74l8n7jrDus8MM6aY+5JHbId Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="337436962" X-IronPort-AV: E=Sophos;i="6.00,183,1681196400"; d="scan'208";a="337436962" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2023 00:09:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="773212660" X-IronPort-AV: E=Sophos;i="6.00,183,1681196400"; d="scan'208";a="773212660" Received: from yhuang6-mobl2.sh.intel.com ([10.238.5.152]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2023 00:09:19 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , David Hildenbrand , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , Minchan Kim , Tim Chen , Yang Shi , Yu Zhao Subject: [PATCH -V2 0/5] swap: cleanup get/put_swap_device() usage Date: Mon, 22 May 2023 15:09:00 +0800 Message-Id: <20230522070905.16773-1-ying.huang@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: E721E1A0017 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: iczod5xaxjisz5qk9fxmq6g3rf3qhnou X-HE-Tag: 1684739375-899258 X-HE-Meta: U2FsdGVkX1/ddB5hcSoFLBs8fjRwktbx9Q5kL7RUVnOj29/oYf75E+QGZBlJoisoRkXwrakfp6DxjLRGgrnT19yzlfm6x6oKrjC1OD+VzD9dMjTSQIRTBzZL1HrvHpA+DOfSnpn3/ptF03UCy6K3KXNY/ts2dYaKMIu8vAxow9F6rKp7+kIvaVOzbniQFIsxL+EV/5ZLCyKgJ35jqXeRsXTxCKSC4dlCfSTuxQlzVxlctNVSdN6gLRioWZWFhYw3twUSZkBR/twP/YVCjKfSYkNce7iVfMIYFF94bN2702WJt45gp7Qm88h8Qy++oiyjUzt6Z7wEq+vx//QsZGFLzhfkQ+sPuOZJTYekez7h4epM3D6W9aPINNFkdgNxKamRTekk+uiKLGHC6O4zsS6ETVYP8bL+lzMa6JqenjqMKwNmSY6m74NCVqRy1CVyapMcmApf/BT9b3zsdR+2EZBj0WN9Ae1mLn7EwzgWgMfmhibMd0ewSYn4FhilYT4ZOxmzJAvwldoSd2J9WS9dpzytCjVanw7c32qnbrKvXIqCD4WbhKQ7du//yn0hWVybg/wHlLq2Q4/77HZW3JnaQujBT2IpiP9FtU9Hw/GrtBk/2D8SWIDh4Kz8cST5246nGd5mzKxSQvuObGJvZrgks0oFaZhvfQeSSpXP/NdBRYNfoQW8ArVfeIUWK5ys/vdjKoH4F8v+CmBkDlRgd6yR84P2WOimFB+TwruTr8VUugRWIPofqo6jL7DhIuuuQX3nwsEn6Y4MM6yAZLq17WXMwvqJd4YexbySpTbhP6eMVxti7/gKJRyEGPAyPhuqa+tU5wbrDAZyHFTlTPy1j4CDmfQJk34JgoEB00EZnSpaX5c51CLULdJ9kylBrf5wPhyAKKdi6HsCce9CWK8M+tBgjSCk5Hm6rcTt9rB6r7JZYVWnny2PEhoUtWuCbLwGU3disguzf/K7hsQriOFeW+pcAhh 0oh3D73m /wkDEgTNyRpmuzBn4TLn6y2VZzego4ElBJrHI+rJHZVnhDdZRO3w7s7FOqCD9dVliI2233YzxYyYL3IxkP8l2DNTwTfBM5Sfn7KzTQDdWb+wuIr0QFA/nSxvkEbit06b26N0nQMBBf+6dTxVlXThwpP37hCPWRmYLhBivGLS3MbBMwZx2Xw9gEqGlng== 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: The general rule to use a swap entry is as follows. When we get a swap entry, if there isn't some other way to prevent swapoff, such as page lock for swap cache, page table lock, etc., the swap entry may become invalid because of swapoff. Then, we need to enclose all swap related functions with get_swap_device() and put_swap_device(), unless the swap functions call get/put_swap_device() by themselves. Based on the above rule, all get/put_swap_device() usage are checked and cleaned up if necessary. Changelogs: v2: - Split patch per David's comments. Thanks! Best Regards, Huang, Ying