Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4735178imm; Mon, 11 Jun 2018 18:25:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJXEGDu6YG5CuNbMVvjJL8Gct3D7ZjpNNBMg+bt9RcMLM6Ui5zEIeFaA+XDgYbm5n/7lmAw X-Received: by 2002:a63:2f04:: with SMTP id v4-v6mr1281788pgv.33.1528766707258; Mon, 11 Jun 2018 18:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528766707; cv=none; d=google.com; s=arc-20160816; b=LSVn8vslxyJtP+ZjOUqc/ItgrsS/IjnAJ/KXcvMOPelYIJ6qxr16hfAIyhGWBmBA7w /3kSPrnpmjvYl04dlKjLRnoLZhgxAAEKS5QoTp8g/Z8UXVOQTCGpGzfxj0hFHY4erGK8 l52hX6njUAwJMgxnTfJ+maDZsNgUSczlVq3ws8pnAzw1yu7LzGvDhp044g/cZwg55FnX j9FbrB8fmtxPYYvLDbIqRdWCXP9t+tz6oKkPra1jTN+guhqGjgMnFGPasvCsFCYbxGG5 Bf5+kU3GnHB1CtB5/kTPRdE3fnI0gaAvZ7xI/fv+pG5llD/ZnyTVXbiX8nLCEPJn9vQq RlZA== 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=WdRd95gkUVtGdBV9+e/57mpTnK7zmdyOQDo7pWL9wMI=; b=AfYFfYmwEuX7VYbs32A+CCpIKVgt+IjjgOy+kgFwUa4zU5qUnxP/oyidiOW0hUCULd NfU/Fv4oU66Kn5f9unyyABINU/GRE1CJicUFAziSx7jGRHSDWrNfhGvPlSj53HPDK16o SNAekc1raO5kyGLliGpkRj9OYBAr3DhnVag7fZ2CEbB2uYZnYd2rz74Fe3xwsgw3dqra HBzPKD5XYUnwBX4GN9pkE49mvv78DQeoqccCmhHpXLorcDm328NOHpAnnF5CSazYj0bC uWN5x6nem1i771Wuj1zFzbDvfQNS/hdppmmMSl4wI52I75q17FQJGRq2QLPZbShwoidT GB9g== 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 v30-v6si29001709pfl.233.2018.06.11.18.24.52; Mon, 11 Jun 2018 18:25:07 -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 S934904AbeFLBXZ (ORCPT + 99 others); Mon, 11 Jun 2018 21:23:25 -0400 Received: from mga02.intel.com ([134.134.136.20]:36981 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932893AbeFLBXX (ORCPT ); Mon, 11 Jun 2018 21:23:23 -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 orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jun 2018 18:23:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,212,1526367600"; d="scan'208";a="49117070" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.13.118]) by orsmga006.jf.intel.com with ESMTP; 11 Jun 2018 18:23:20 -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 -V3 03/21] mm, THP, swap: Support PMD swap mapping in swap_duplicate() References: <20180523082625.6897-1-ying.huang@intel.com> <20180523082625.6897-4-ying.huang@intel.com> <20180611204231.ojhlyrbmda6pouxb@ca-dmjordan1.us.oracle.com> Date: Tue, 12 Jun 2018 09:23:19 +0800 In-Reply-To: <20180611204231.ojhlyrbmda6pouxb@ca-dmjordan1.us.oracle.com> (Daniel Jordan's message of "Mon, 11 Jun 2018 13:42:31 -0700") Message-ID: <87o9ggpzlk.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 Hi, Daniel, Thanks for your effort to review this series. Daniel Jordan writes: > Hi, > > The series up to and including this patch doesn't build. For this patch we > need: > > diff --git a/mm/swap_state.c b/mm/swap_state.c > index c6b3eab73fde..2f2d07627113 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -433,7 +433,7 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, > /* > * Swap entry may have been freed since our caller observed it. > */ > - err = swapcache_prepare(entry); > + err = swapcache_prepare(entry, false); > if (err == -EEXIST) { > radix_tree_preload_end(); > /* Thanks for pointing this out! Will change in the next version. > > On Wed, May 23, 2018 at 04:26:07PM +0800, Huang, Ying wrote: >> @@ -3516,11 +3512,39 @@ static int __swap_duplicate(swp_entry_t entry, unsigned char usage) > > Two comments about this part of __swap_duplicate as long as you're moving it to > another function: > > } else if (count || has_cache) { > > if ((count & ~COUNT_CONTINUED) < SWAP_MAP_MAX) /* #1 */ > count += usage; > else if ((count & ~COUNT_CONTINUED) > SWAP_MAP_MAX) /* #2 */ > err = -EINVAL; > > #1: __swap_duplicate_locked might use > > VM_BUG_ON(usage != SWAP_HAS_CACHE && usage != 1); > > to document the unstated assumption that usage is 1 (otherwise count could > overflow). Sounds good. Will do this. > #2: We've masked off SWAP_HAS_CACHE and COUNT_CONTINUED, and already checked > for SWAP_MAP_BAD, so I think condition #2 always fails and can just be removed. I think this is used to check some software bug. For example, SWAP_MAP_SHMEM will yield true here. >> +#ifdef CONFIG_THP_SWAP >> +static int __swap_duplicate_cluster(swp_entry_t *entry, unsigned char usage) > ... >> + } else { >> + for (i = 0; i < SWAPFILE_CLUSTER; i++) { >> +retry: >> + err = __swap_duplicate_locked(si, offset + i, 1); > > I guess usage is assumed to be 1 at this point (__swap_duplicate_locked makes > the same assumption). Maybe make this explicit with > > err = __swap_duplicate_locked(si, offset + i, usage); > > , use 'usage' in cluster_set_count and __swap_entry_free too, and then > earlier have a > > VM_BUG_ON(usage != SWAP_HAS_CACHE && usage != 1); > > ? Yes. I will fix this. And we can just check it in __swap_duplicate_locked() and all these will be covered. >> +#else >> +static inline int __swap_duplicate_cluster(swp_entry_t *entry, > > This doesn't need inline. Why not? This is just a one line stub. > Not related to your changes, but while we're here, the comment with > SWAP_HAS_CONT in swap_count() could be deleted: I don't think there ever was a > SWAP_HAS_CONT. Yes. We should correct this. Because this should go to a separate patch, would you mind to submit a patch to fix it? > The rest looks ok up to this point. Thanks! Best Regards, Huang, Ying