Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1406399rdb; Tue, 30 Jan 2024 18:53:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IE67nSOLTNHwz7HRrokDYrsIsqwM/U9TDGdZglfSXn1VbtxdZDls+8X65sjGo2PcB+rJ+SH X-Received: by 2002:a05:6402:1d14:b0:55e:b942:aaab with SMTP id dg20-20020a0564021d1400b0055eb942aaabmr126528edb.23.1706669629741; Tue, 30 Jan 2024 18:53:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706669629; cv=pass; d=google.com; s=arc-20160816; b=E0ovgDSZlCPttqjnXjkWoYxdK4HXAPxSIwHtH17vONb5RiXGGStGk9wpvION/EssNa Zsy0CWmHUc/vXpXHkg1dgOW+GkcWzg398+XDxns/ZLDujsEJA+C81/DuMkJy0WmJFiQ0 J2FPec+r5WUNYuoQjTgN/5pkRrMb18hKOeKZMkwzf33jjXRro4nUVuL7aLF5ctG+AEeB BwKVhWJACXvtna7TVXrO5/fAg6jF9GMFlQUvo+gtR7ykLJzNPLJBoBsL5WFeiOaLjF4T c9+4uvcMHJSNDhqjWa/cEYqRGruyJLOqW/QIzbUegha1azb28BVWjKKLUT4sNGhHrKdG bgKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=J8hjQ+DyDgAXWzaI96gTb2WvWhEL6V2cFr2k9CHQYzU=; fh=b9wCAWoOOicW5f4Fqp8jkDn+T26pV/5/xk6v5gP5Ats=; b=HSHQNr/ivKr3kJ40YCC94n9psYCnvb5I+S2UvHPYt20EL+Tfdblrs8RLKxBarTIc4T 9Lu2VQUShuFTq9o1YhdtbhY8dIawHcOPq3L28b6q3PgCRotlja99PbRM1p492ZRTLVIT ehQ3OGhWX+m5xnzEUpM7d56EDy/tC4vW3mGs8wni4SwTD3vHbPw7DkvpAK0qoWMRHzKK 8CkEriPooeG4AyMt/iF3DAZlmbUD93LAWuMSfak2GpkoH3j87bD6X27NE/t93w5tLxTI e2CEOCjM2S/Y4fPLN8Tyr6zYBaB27pHjnCFguN/ifvFyaxfALuJtgUxUqS3cSfve4U/S yMCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EduG1WCO; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-45694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45694-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCWEOrrocZQO2vGzS+ShB4YLpSYASJKOMd16GPeTKEtcS0eRyd4sBd9ptKz90HTACeUaXVpfa6ghY7+9OI3HvzxwAyb1cMQqs5CeuFrlog== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id er20-20020a056402449400b0055ee0391aa0si3347447edb.597.2024.01.30.18.53.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 18:53:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EduG1WCO; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-45694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45694-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7E6171F2534A for ; Wed, 31 Jan 2024 02:53:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91695FBF3; Wed, 31 Jan 2024 02:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EduG1WCO" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4599AF9F0 for ; Wed, 31 Jan 2024 02:53:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706669620; cv=none; b=jCS4c7rhsxKx54Zi7vcZg66NnjwkfM/ntDvl7bv22nEwCP2AhKXzuU7myhXTfIM3wN5QEouXUomt6Ry5rU5AFyyjnNBZxyw1xuFdh5coWXjL4zRSt9axjgoLehgidp7rUqHIIEiGCMQwzYN5ippN+HcDbY3pAqlYtpFZPlNp9ec= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706669620; c=relaxed/simple; bh=fkrZop1jEqx5HXBSyzDbQgSqp95ndkCeM35935mkvCw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=ocRgIMC7w/Qpp3MFMJcZeXUpPKx8apAOt9OW8YZ8wU9GhpeuDmFNs7FQpX/jKWuC/FegvcJEN9e9NNNFXc5C+aoA8P/GCmALCEGaZaxAOXozO5+RsqALAzhDEuA8O60IzM5b+LAho0hNpMZyQAJiI94Wzg9cbwCWJVdVmyDsHfo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=EduG1WCO; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706669619; x=1738205619; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=fkrZop1jEqx5HXBSyzDbQgSqp95ndkCeM35935mkvCw=; b=EduG1WCODgogplh6177erkxQbrzwUEB0mFHr9w6a/LlV00R6Fy4KgGJ/ MYqJ60F/P7zCBhRkyDLLv+GEHkf6rPoV6XbwvF1RfK0ql6/UmTIyG+ho+ gQGbAw98kVTeonApomtkBOzsgmK5YB02bOYyufhznwwTNVgSt4FMscAEc FKdK3XIagXo/wrnHSpXgQaeBjtpiSbS13Ula9bg6bQqEleDsQstX3cQcS /4SwfbGUlcBrU+/wbinYXRAbpz0XBP+RfVjQj3Q+/jJXkN7PZHLejvZnv R/MSxOSW3nh4cOH0SjWQrSMEXz6/ADe3tQV9JDUbfungihQuZXRZVStGt g==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="16855252" X-IronPort-AV: E=Sophos;i="6.05,231,1701158400"; d="scan'208";a="16855252" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2024 18:53:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="961469677" X-IronPort-AV: E=Sophos;i="6.05,231,1701158400"; d="scan'208";a="961469677" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2024 18:53:35 -0800 From: "Huang, Ying" To: Minchan Kim Cc: Kairui Song , linux-mm@kvack.org, Kairui Song , Andrew Morton , Chris Li , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , Yosry Ahmed , David Hildenbrand , linux-kernel@vger.kernel.org, Yu Zhao Subject: Whether is the race for SWP_SYNCHRONOUS_IO possible? (was Re: [PATCH v3 6/7] mm/swap, shmem: use unified swapin helper for shmem) In-Reply-To: <20240129175423.1987-7-ryncsn@gmail.com> (Kairui Song's message of "Tue, 30 Jan 2024 01:54:21 +0800") References: <20240129175423.1987-1-ryncsn@gmail.com> <20240129175423.1987-7-ryncsn@gmail.com> Date: Wed, 31 Jan 2024 10:51:38 +0800 Message-ID: <87bk92gqpx.fsf_-_@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Hi, Minchan, When I review the patchset from Kairui, I checked the code to skip swap cache in do_swap_page() for swap device with SWP_SYNCHRONOUS_IO. Is the following race possible? Where a page is swapped out to a swap device with SWP_SYNCHRONOUS_IO and the swap count is 1. Then 2 threads of the process runs on CPU0 and CPU1 as below. CPU0 is running do_swap_page(). CPU0 CPU1 ---- ---- swap_cache_get_folio() check sync io and swap count alloc folio swap_readpage() folio_lock_or_retry() swap in the swap entry write page swap out to same swap entry pte_offset_map_lock() check pte_same() swap_free() <-- new content lost! set_pte_at() <-- stale page! folio_unlock() pte_unmap_unlock() Do I miss anything? -- Best Regards, Huang, Ying