Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1401045imm; Tue, 10 Jul 2018 00:50:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcOkkS7mL7XkUutx1y84p7rDxxYZ5pEpjdnYqsEtXqaOo70gADfVzarB0aaEuzq9p0qBXFw X-Received: by 2002:a65:41c6:: with SMTP id b6-v6mr21375497pgq.174.1531209056816; Tue, 10 Jul 2018 00:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531209056; cv=none; d=google.com; s=arc-20160816; b=NGFfX8RUSzQ9cP6evDC5iF1AzFKm///ZwczhWYGthT5RlJBRaQ9BRR83clHfZiWI55 aSxTAsBxrvdrIKlBolxKleWc4aklEuWgbYXXgxVSSbmx4tarxZKqoXmsvbzL7WtFIXqz huweGlLLVXtwYPq/0iHcqj0m86ewlUPo/+2QpBg2zF0ZIFmZevrhIZXPRw8VzeS/uIJY EvG1ESpFvJ4xkkBh/Yrtugp+KyeJRyAICzBRdYflYKSX3DuQwme64X4jvf+LhwH3JXhW 6+aQHdK/GqUDTzKZq9zyyU9AyNs7/CAzZF1KZn1Ej8ZovETfY/dhuwtlSY+uSM/apqph byTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=klNGlHEZlD1pTfs3FJRTT93hez4U29YJB382pEzdyj0=; b=BCG2Or5kVsi37t4omrWLsm0nLhJBlSbaCUD13Ann9FkYmY1V6gbEYV1a8crtGohR9L ai287kWn9XfNEKdRjKoNum3Ffi1L77xz1+pNnaucX53O8MFrUf8ISL4g2TNebgbdnck0 svO7WzyQu645CGOaLyadg50UitPFbPu2sAIVpOHtaZeAtQAfHWIg4vtOp4tI5jrCiN0o JMtEaxNu5EFT8y3XOhdsMZpHsQ7xQIP73pLP4ucbezQKSx/RBI3sPnFAbNcnmyn0+Vp7 u195PC+nRy1uP5eUDLFCpsY/jvNufqPneE7uGZIRTzioA8jFPzxVt4HjNo7TkcQrwMwa twHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c31-v6si12746678pgl.126.2018.07.10.00.50.41; Tue, 10 Jul 2018 00:50:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751214AbeGJHuD (ORCPT + 99 others); Tue, 10 Jul 2018 03:50:03 -0400 Received: from mga04.intel.com ([192.55.52.120]:20189 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751047AbeGJHuB (ORCPT ); Tue, 10 Jul 2018 03:50:01 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2018 00:50:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,333,1526367600"; d="scan'208";a="55346431" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.13.118]) by orsmga007.jf.intel.com with ESMTP; 10 Jul 2018 00:49:58 -0700 From: "Huang\, Ying" To: Daniel Jordan Cc: Andrew Morton , , , "Kirill A. Shutemov" , Andrea Arcangeli , Michal Hocko , Johannes Weiner , "Shaohua Li" , Hugh Dickins , Minchan Kim , Rik van Riel , Dave Hansen , Naoya Horiguchi , Zi Yan Subject: Re: [PATCH -mm -v4 14/21] mm, cgroup, THP, swap: Support to move swap account for PMD swap mapping References: <20180622035151.6676-1-ying.huang@intel.com> <20180622035151.6676-15-ying.huang@intel.com> <20180709172037.254zyuadep2hj5po@ca-dmjordan1.us.oracle.com> Date: Tue, 10 Jul 2018 15:49:58 +0800 In-Reply-To: <20180709172037.254zyuadep2hj5po@ca-dmjordan1.us.oracle.com> (Daniel Jordan's message of "Mon, 9 Jul 2018 10:20:37 -0700") Message-ID: <87tvp7h6mx.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Daniel Jordan writes: > On Fri, Jun 22, 2018 at 11:51:44AM +0800, Huang, Ying wrote: >> Because there is no way to prevent a huge swap cluster from being >> split except when it has SWAP_HAS_CACHE flag set. > > What about making get_mctgt_type_thp take the cluster lock? That function > would be the first lock_cluster user outside of swapfile.c, but it would > serialize with split_swap_cluster. > >> It is possible for >> the huge swap cluster to be split and the charge for the swap slots >> inside to be changed, after we check the PMD swap mapping and the huge >> swap cluster before we commit the charge moving. But the race window >> is so small, that we will just ignore the race. > > Moving the charges is a slow path, so can't we just be correct here and not > leak? Check the code and thought about this again, found the race may not exist. Because the PMD is locked when get_mctgt_type_thp() is called until charge is completed for the PMD. So the charge of the huge swap cluster cannot be changed at the same time even if the huge swap cluster is split by other processes. Right? Will update the comments for this. Best Regards, Huang, Ying