Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2330925imm; Tue, 10 Jul 2018 18:30:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpekt3AI4PaBt1ExuYN2uM+P3j2xfOpl9AQtgjY5+hjQz+x4W4xJIMQm+KvaDst7SHabzC5q X-Received: by 2002:a63:4306:: with SMTP id q6-v6mr23868743pga.181.1531272623945; Tue, 10 Jul 2018 18:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531272623; cv=none; d=google.com; s=arc-20160816; b=BzRHZkxfN8zvkCROJLHMKNqP6vRHLCvdP1NwuSKxdm0xibw5OWEUYZwcLLGAKH1t4V g0/ABltT/b8U4D3+j+33FwUp7557rM3EQcfPE5sBKM32/b8G1jDxK3IiYVRxx0WLlkKz zzLsQr+EYVrZHCQ1Z74nZVk6Pw8G30xf1PkSyAntz7OlC//uc9a5lc3S73zrTNv9P1tU yhprzzm3TGj0m3rEMdukkuZNnHdY5l5Ae+vqnSYGe4cywCUjKriCiSBgMqHCuptBAr2B mlej2hp8XZYFPkn2SNF6u3kmwM1lAlRozIRmo4qyaVhMzSVK2L5p3YVSIuOaQv0cdxi4 bauA== 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=/lYfEBV/lBO8Lif2p2DAtBojzgHA3qwt6vBh8dKmNDQ=; b=d2If3VXa8IsL7lXRVo1NQnk9KwdaoIgRieGw77ofRbcesfyfe5HPrdp372DTNm0Ql9 H/UYYWKw8SwnACNE9BuVaeQ/lSUM4CT9NiVo/m54tbF/2LpzUvMBz64fdmMRcNmVcV1H yMnYQZF8YKJ6+6NRMIAqQrwdjQ4mhEx1PKRnys98+tMtfstpb2S076BNknJvRgagMzxD NTMZCV2+f8viWekoyoqaGWu28CQUBT1rGDmjsb38YpcsYfMHw9l6zjBL2EJsK/gt2EzI mnhlovz1akejp7Syu4sQwA2aX3QXl5MZw4OIqvo+2gnpAOgIf5N+QWbBM39XktZFF/Va Z8QA== 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 k20-v6si1842778pgg.7.2018.07.10.18.30.08; Tue, 10 Jul 2018 18:30:23 -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 S1732378AbeGKBaR (ORCPT + 99 others); Tue, 10 Jul 2018 21:30:17 -0400 Received: from mga06.intel.com ([134.134.136.31]:38325 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732304AbeGKBaR (ORCPT ); Tue, 10 Jul 2018 21:30:17 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2018 18:28:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,336,1526367600"; d="scan'208";a="56702276" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.13.118]) by orsmga006.jf.intel.com with ESMTP; 10 Jul 2018 18:28:14 -0700 From: "Huang\, Ying" To: Dave Hansen Cc: Andrew Morton , , , "Kirill A. Shutemov" , Andrea Arcangeli , Michal Hocko , Johannes Weiner , "Shaohua Li" , Hugh Dickins , Minchan Kim , Rik van Riel , Naoya Horiguchi , Zi Yan , Daniel Jordan Subject: Re: [PATCH -mm -v4 05/21] mm, THP, swap: Support PMD swap mapping in free_swap_and_cache()/swap_free() References: <20180622035151.6676-1-ying.huang@intel.com> <20180622035151.6676-6-ying.huang@intel.com> <49178f48-6635-353c-678d-3db436d3f9c3@linux.intel.com> <87y3ejh8ax.fsf@yhuang-dev.intel.com> <836c95a7-5f03-6d9e-6f0a-839b5fb8ba99@linux.intel.com> Date: Wed, 11 Jul 2018 09:28:13 +0800 In-Reply-To: <836c95a7-5f03-6d9e-6f0a-839b5fb8ba99@linux.intel.com> (Dave Hansen's message of "Tue, 10 Jul 2018 07:07:39 -0700") Message-ID: <87h8l6h87m.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 Dave Hansen writes: > On 07/10/2018 12:13 AM, Huang, Ying wrote: >> Dave Hansen writes: >>> The code non-resuse was, and continues to be, IMNHO, one of the largest >>> sources of bugs with the original THP implementation. It might be >>> infeasible to do here, but let's at least give it as much of a go as we can. >> >> I totally agree that we should unify the code path for huge and normal >> page/swap if possible. One concern is code size for !CONFIG_THP_SWAP. > > I've honestly never heard that as an argument before. In general, our > .c files implement *full* functionality: the most complex case. The > headers #ifdef that functionality down because of our .config or > architecture. > > The thing that matters here is debugging and reviewing the _complicated_ > case, IMNHO. I agree with your point here. I will try it and measure the code size change too. >> The original method is good for that. The new method may introduce some >> huge swap related code that is hard to be eliminated for >> !CONFIG_THP_SWAP. Andrew Morton pointed this out for the patchset of >> the first step of the THP swap optimization. >> >> This may be mitigated at least partly via, >> >> ` >> #ifdef CONFIG_THP_SWAP >> #define nr_swap_entries(nr) (nr) >> #else >> #define nr_swap_entries(nr) 1 >> #endif >> >> void do_something(swp_entry_t entry, int __nr_entries) >> { >> int i, nr_entries = nr_swap_entries(__nr_entries); >> >> if (nr_entries = SWAPFILE_CLUSTER) >> ; /* huge swap specific */ >> else >> ; /* normal swap specific */ >> >> for (i = 0; i < nr_entries; i++) { >> ; /* do something for each entry */ >> } >> >> /* ... */ >> } >> ` > > While that isn't perfect, it's better than the current state of things. > > While you are refactoring things, I think you also need to take a good > look at roughly chopping this series in half by finding another stopping > point. You've done a great job so far of trickling this functionality > in so far, but 21 patches is quite a bit, and the set is only going to > get larger. Yes. The patchset is too large. I will try to reduce it if possible. At least [21/21] can be separated. [02/21] may be sent separately too. Other parts are hard, THP swapin and creating/supporting PMD swap mapping need to be in one patchset. Best Regards, Huang, Ying