From patchwork Fri Mar 3 03:01:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 13158301 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 3ABFEC678D4 for ; Fri, 3 Mar 2023 03:02:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A10D36B0074; Thu, 2 Mar 2023 22:02:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C1026B0075; Thu, 2 Mar 2023 22:02:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 888906B0078; Thu, 2 Mar 2023 22:02:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 78A4E6B0074 for ; Thu, 2 Mar 2023 22:02:25 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 49BD0120E3B for ; Fri, 3 Mar 2023 03:02:25 +0000 (UTC) X-FDA: 80526088650.30.46CF291 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf19.hostedemail.com (Postfix) with ESMTP id E6FBE1A0007 for ; Fri, 3 Mar 2023 03:02:22 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=UClygxn8; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf19.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.43 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=1677812543; 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=uo/KhBagqhRpY/vTp5FG6/hz+/Ksb64PvlTAgdn/Kp4=; b=dsh0MOBLOdXPt+2K/3NdlOI1OharjQcZfkFKc6PTcG8ms/d0XDJ5Htyna+vmbI9llENJiN L4PS0YWmacpzcBBcPq78l5CO3p2F+60fG6VWTSr/LFjF3Yuh+HplwQbOmoXMm8FkRRjELW bapiAf9EQlA3vueIF9Hl8PlGCuI4M0w= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=UClygxn8; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf19.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677812543; a=rsa-sha256; cv=none; b=ulywOMigGqq4JOFlIZm8MSKtQoE+2yOU/PsBtcKSQmOlqGl9QNRzmIjrZBVT4ZAWdsirI6 YsLj/0dNihg8LxpiPOWoDJ7SpJEl8o5W8xsI5HvW1uNVdUVrn1WcIxR3YNtyPR105v7Zz/ NLmh8yzQTjCNhWWGN5xA1nMjYifa7iA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677812542; x=1709348542; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=G3zRk1EKAJOu7vQd/yH73yVtZIFRGseFJ2N2fMBTDwk=; b=UClygxn8Ui5ueW5jXd/uEHzzOmcZnoIseKXB2crQQtd4auzAxkLq+NXZ 7INZxQ/UzaguQL6Z4DtDyxy9MCdLawbBRBc2N8gKrQylPxXp+Su9Et3qF BdS8lQbyOuSwL1erfdaM6AnprEHFJ7g9Anxt0cAtWguWHD/qGUvKCJKu4 Za+A2uhY8Y8piXw819SDs2uQeTfZGSyywygjqSRSdTC893FfO8oBbN3Vj 6nC6CUyJLLZV+l0DAs8T4VBbyRvRqNtnHWCjDdJOOP2WyfGhKhSkHW5/d f3Ud3J+7+t9TbILDTKYDe2p6vrnG6w+12QdnL3j4V+Ub9z5wtavpENGfW w==; X-IronPort-AV: E=McAfee;i="6500,9779,10637"; a="421207077" X-IronPort-AV: E=Sophos;i="5.98,229,1673942400"; d="scan'208";a="421207077" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2023 19:02:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10637"; a="668497679" X-IronPort-AV: E=Sophos;i="5.98,229,1673942400"; d="scan'208";a="668497679" Received: from xinyumao-mobl.ccr.corp.intel.com (HELO yhuang6-mobl2.ccr.corp.intel.com) ([10.255.31.231]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2023 19:02:17 -0800 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Hugh Dickins , "Xu, Pengfei" , Christoph Hellwig , Stefan Roesch , Tejun Heo , Xin Hao , Zi Yan , Yang Shi , Baolin Wang , Matthew Wilcox , Mike Kravetz Subject: [PATCH -V2 0/3] migrate_pages: fix deadlock in batched synchronous migration Date: Fri, 3 Mar 2023 11:01:52 +0800 Message-Id: <20230303030155.160983-1-ying.huang@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: E6FBE1A0007 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: kr9e4drhfdumkzuon8femwutsce364ft X-HE-Tag: 1677812542-85768 X-HE-Meta: U2FsdGVkX18uKH43hq7j1V0YiP42PX5/DPQ8d6K6GHNAFbppbFFSxpT5wld/rVyOy24MmJ6t/Qh182l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Zm 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: Two deadlock bugs were reported for the migrate_pages() batching series. Thanks Hugh and Pengfei. Analysis shows that if we have locked some other folios except the one we are migrating, it's not safe in general to wait synchronously, for example, to wait the writeback to complete or wait to lock the buffer head. So 1/3 fixes the deadlock in a simple way, where the batching support for the synchronous migration is disabled. The change is straightforward and easy to be understood. While 3/3 re-introduce the batching for synchronous migration via trying to migrate asynchronously in batch optimistically, then fall back to migrate synchronously one by one for fail-to-migrate folios. Test shows that this can restore the TLB flushing batching performance for synchronous migration effectively. Changelogs: v2: - Rebased on latest upstream. - Restore the total retry number of synchronous migrations and removed "force" logic from migrate_folio_unmap(). Thanks Hugh! - Revised some comments per Baolin's comment. Thanks! - Collected reviewed-by and tested-by. Best Regards, Huang, Ying