Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2738048rwd; Sun, 28 May 2023 23:23:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4TCoLYz7uytOMLVoGj1RLY0X2/ObtzTK8UcJB6LoW/gMw1XahLaLFeBYJMdRgcPcuTFTqB X-Received: by 2002:a05:6a00:2d98:b0:63d:45f3:9fc with SMTP id fb24-20020a056a002d9800b0063d45f309fcmr7257305pfb.5.1685341384102; Sun, 28 May 2023 23:23:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685341384; cv=none; d=google.com; s=arc-20160816; b=0t/kIMI2UNODdJMCk9r49HYK0fx+X3ab9671S5WpKVMLPlGK8me5dOU8hgqh+UpYwg R6EhFUlGtd5rPTjKo547HCVnXA/ioQkXCNDElwEuQWue7+GGkosJn1HOVWnMbsgcAHZw DoKzpVc5jflJm+X7jEyzcmai+WhdNPez+4mpGZhvyyRJyE+l116wXpsVl4eXisPPq3uJ E/O0vzU2RfG+F1HYaH722640EkqlGsiBI1CQ3M9HHwigTuha2aSaDcLJtbrSNE+O1hKm PZNPTJFq6bq4ZkfieATMFLMSXiphFOgiJYq8QR3sHG4pEdX2H0tpXH3qXCX0t0vrcc5x v34g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=aUy/JryjGSlpC3TCt9Xk24fhImxIYPcAwmgZjW9oHR8=; b=I54ElwccgpX3WzIukVVBfGpEBZt80rfUCI3dfpKaryytZrNuufZ5TZkPwURc5EnH7q U8Pnko2TU5UVKyyDdiC7pSfv86bd5mEMLCSaTF0tZgHnBEItJkScVJ8JawS1gIgUaFHi pm1zyND+HPwkQLZSckwpNMKkYsYmcpW60OhSh66sJ8AwzUjkVDZIcqW46qiFzxcZDpLg RhacMGOJQTXld2uMMuIO1mA8Vk/EsuPIUtYGm4xcwWouXZtkYt6PsqkB4dC6/eapikEG niWgRVEdJtlM+Ux7IIRtl5pnM+opjFvmER9/ZNVbSteHVeqmaBZSjALiwnh4BVcLqGGo oOGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a2TAUepa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x18-20020aa79ad2000000b006436002d796si5434972pfp.1.2023.05.28.23.22.49; Sun, 28 May 2023 23:23:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a2TAUepa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbjE2GOS (ORCPT + 99 others); Mon, 29 May 2023 02:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbjE2GOQ (ORCPT ); Mon, 29 May 2023 02:14:16 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0BD7B1 for ; Sun, 28 May 2023 23:14:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685340855; x=1716876855; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=lZvg1L57BcoSEw3CqHyDTtH9MeFq1P/MjhjyoIG9cOk=; b=a2TAUepaXSB/fUm74HgmOqxRji0GG/eqXp4N7Z05TEgTg/r4NWk+UQnN sxZ5JMrjPYndaU2lLBwgr4K+wOtY1i8+URqfzj91LMOc+0DFprwRqvwZL worAsq9F85nrieVk4MrOiXmhVXLwt/ww5OHRg/bf1Gdjuoivm0SzHaK3P KJ1tmoORBuL5sg97/qpml70D8llJBicVbhz9yFiXbPzke8DbxRAng3/r3 4CB80VVOvSUzWLjHzr4pJe+ds7x1jITW8RQMIdqW68/MWpCTRYBNADTn3 YAeoYQYxjstIyz8DdjScxSD6nNegmF+Cu65M2wGe2TsRFC+U0jugMzbCC w==; X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="357881762" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="357881762" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 23:14:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="1036079969" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="1036079969" Received: from azhao3-mobl1.ccr.corp.intel.com (HELO yhuang6-mobl2.ccr.corp.intel.com) ([10.255.28.126]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 23:14:11 -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 , Chris Li , Yosry Ahmed Subject: [PATCH -V3 0/5] swap: cleanup get/put_swap_device() usage Date: Mon, 29 May 2023 14:13:50 +0800 Message-Id: <20230529061355.125791-1-ying.huang@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The general rule to use a swap entry is as follows. When we get a swap entry, if there aren't some other ways to prevent swapoff, such as the folio in swap cache is locked, page table lock is held, 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: V3: - Fix build error in [2/5], Thanks David! - Fix comments and patch description about the folio in swap cache, Thanks David! - Collected reviewed-by. V2: - Split patch per David's comments. Thanks! Best Regards, Huang, Ying