Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1374372imm; Tue, 10 Jul 2018 00:15:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpczAMaSBo+qiDQFFP0Y89JaDyXh11XlYnguqW7/++aMxT7pRQ0hYUYwXuwZvclby8M4LbNG X-Received: by 2002:a62:dc8f:: with SMTP id c15-v6mr24521449pfl.155.1531206906710; Tue, 10 Jul 2018 00:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531206906; cv=none; d=google.com; s=arc-20160816; b=hhBumrAqSS7KfsvwPd83lVYLk7zwFI25ApJrisFvbmasrqSpeT5Z5qp+K2nACyDjyR CFiQSMwIRJrrBL/S0cwfVpS2Y5pK+lA5YHf+j0XlMEvqzBSC2BkdcwuWzLozmJ0sau1k FwfKbTZNtv0e2+ia3gohpQJZM/ItGH/141k1NZ7qd+2T3SbJh8kodrNgosjVdb+XVAzm 592W0dkKGTsVZRtvTpzaqWZlYonVO7E4tHLOAZR2MwXAfY4+VS1S5WK5vrP4BoeaflP3 tYYwkcAvAfP+6Um9T7nDpVC5oTnKsGmcGE7QL7UMD6aPCgMXwPStjhb6GoRBi9ymyumD QnPQ== 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=ENxJ/5Pqm/UIVaT2yKzTN3KVoDou6sg79H+kpRTz+Vg=; b=a+0O2UsedeFTkuePg6hUjvqazz210hzXnlgq8Ky5oFsyejt6/+UoaQpA4Ucj3/ezD3 ru+9BDvJDPwlyYtlFkH+j9saeMCZFVhmIvAqx2lRKHJFDgdehmdokuTS0WhgD0XXjy7G TTd1+AmXLKwO82AAnsZJj2z04sjw2n873dc24UCvw26pvJIyI7374KrclQW6XuYQGsrn DEsd31Z/dGXqPwm5OKDp41+BjwP3mhIogMkP0v+QCG0XM03kpxTmRQ9cKNIcExrFjRlB 9HFZwlv2ZexBoiRfyJXkXEKGXJBFeYf+qD7qK/sMlOFKqxoKi6jtHvayMRCQ3mIefeEL UfEQ== 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 d37-v6si16116424plb.481.2018.07.10.00.14.50; Tue, 10 Jul 2018 00:15:06 -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 S1751194AbeGJHOC (ORCPT + 99 others); Tue, 10 Jul 2018 03:14:02 -0400 Received: from mga04.intel.com ([192.55.52.120]:18769 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751047AbeGJHOB (ORCPT ); Tue, 10 Jul 2018 03:14:01 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2018 00:14:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,333,1526367600"; d="scan'208";a="63538422" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.13.118]) by FMSMGA003.fm.intel.com with ESMTP; 10 Jul 2018 00:13:58 -0700 From: "Huang\, Ying" To: Dave Hansen , Andrew Morton Cc: , , "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> Date: Tue, 10 Jul 2018 15:13:58 +0800 In-Reply-To: <49178f48-6635-353c-678d-3db436d3f9c3@linux.intel.com> (Dave Hansen's message of "Mon, 9 Jul 2018 10:19:25 -0700") Message-ID: <87y3ejh8ax.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: > I'm seeing a pattern here. > > old code: > > foo() > { > do_swap_something() > } > > new code: > > foo(bool cluster) > { > if (cluster) > do_swap_cluster_something(); > else > do_swap_something(); > } > > That make me fear that we have: > 1. Created a new, wholly untested code path > 2. Created two places to patch bugs > 3. Are not reusing code when possible > > 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. 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 */ } /* ... */ } ` and rely on compiler to do the dirty work for us if possible. Hi, Andrew, What do you think about this? > Can I ask that you take another round through this set and: > > 1. Consolidate code refactoring into separate patches Sure. > 2. Add comments to code, and avoid doing it solely in changelogs Sure. > 3. Make an effort to share more code between the old code and new > code. Where code can not be shared, call that out in the changelog. Will do that if we resolve the code size concern. > This is a *really* hard-to-review set at the moment. Doing those things > will make it much easier to review and hopefully give us more > maintainable code going forward. > > My apologies for not having done this review sooner. Thanks a lot for your comments! Best Regards, Huang, Ying