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: 6061 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp195309wrd; Thu, 2 Mar 2023 19:04:51 -0800 (PST) X-Google-Smtp-Source: AK7set/vwCUcq7wmZU4hu8Jnwm6SwzRVsOYavEHw3Vauiss9zy7dG3mrGun1szkbISjp8jIoLR6N X-Received: by 2002:a17:907:6e25:b0:878:54e3:e3e1 with SMTP id sd37-20020a1709076e2500b0087854e3e3e1mr57263ejc.73.1677812691344; Thu, 02 Mar 2023 19:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812691; cv=none; d=google.com; s=arc-20160816; b=HNkCVs4G2YgGLvCmvviWCmT4A9U7RC3XaWzLKScPx7GahOS832nY/v47+qEQlqQC0v LC7Bb4AO1NWvFKHSPY7++69y+udMr/gxO4eOt3Hlhb/PAsIZL8IyiLw2I+JoCFY9WKon 2FBnUUSsatbNihuHGXzW08yM4LPhSpKEFePh9+jN72JheQRv4/NLFVOV5oE3crtUIZjV cBnso8/ioH+LhivPZTzq840kCVVyGGscqiiZxfx3UfV6DXLq+ydore4qwkC3645Ztq6R /U8HUPrLh5eu/EfGACpSoKqwY/jNQzxE2qS7EkmXKZrpk0LALvNSYuZ3fURFY+DTNajU n0cw== 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=uo/KhBagqhRpY/vTp5FG6/hz+/Ksb64PvlTAgdn/Kp4=; b=oePTOyKr7mUpr2dmnJPKxdrj7yPdfalR54VWLJI6JTqUp5j5VtCjvOYMOGqkOnXUMY TLXiKemafDyvxjo1zRXFAh+2ZQmUGuuCJab0NTpDIXbn5oZfcJFU9Z3vUbAl6Z7smeGy Tjukk+WppbtZQ4b+o5cn7kHUjdZD/jdYqpv+m054PGC7dBP4PSi1XPg01stQJbV+vhkl XyjIW3yUplozPlc+PHzWyqT9Xict3cAR90yHUE4Ko9gFA7Tw+gU0jhvzuQ6IS/GInFED LQH6WPfVessSUMxPHlofl40RpAS3r+j9lS5qxZFZgNgHCWNSbyXYdYr9GHeK348qODWQ hCsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eWWOkUbd; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz11-20020a1709077d8b00b008b2756c9ebbsi1356890ejc.722.2023.03.02.19.04.28; Thu, 02 Mar 2023 19:04:51 -0800 (PST) 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=eWWOkUbd; 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 S229713AbjCCDC2 (ORCPT + 99 others); Thu, 2 Mar 2023 22:02:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbjCCDCY (ORCPT ); Thu, 2 Mar 2023 22:02:24 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68A485848B for ; Thu, 2 Mar 2023 19:02:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677812541; x=1709348541; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=G3zRk1EKAJOu7vQd/yH73yVtZIFRGseFJ2N2fMBTDwk=; b=eWWOkUbd9fYAe+UzxGzhqTwexWZ03Cl+2dufO3fQzC1r3D4LZMSjEu94 MeUYuQe09ctihaqawsXOEXT2EEYoMjL6QcSPKqBC9uSQugNrptExMjvPC v67Fzbm3+KCX3wU3Cwejj9YVcthlUAqJbrn9d1ispWvM4bhhBQ3mWHr6J 0JhWiRveO5oIk5iBjedgcvkPFm9R1g4nvZFL9DAsJA7Tmd0Eliq69XBB0 xAH4CCJELUD+EHE7556a9rk5xTsi/sOyTXapT5wYTvFUyyea9nOdop/cJ FPm/nbdhUWdBI8DClJp/3jqDquZnVgvY7ht7aET+ZMnKkqhrj6xgjF+4P w==; X-IronPort-AV: E=McAfee;i="6500,9779,10637"; a="421207080" X-IronPort-AV: E=Sophos;i="5.98,229,1673942400"; d="scan'208";a="421207080" 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-Spam-Status: No, score=-4.4 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759314120231635708?= X-GMAIL-MSGID: =?utf-8?q?1759314120231635708?= 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