From patchwork Mon Jun 11 20:42:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Jordan X-Patchwork-Id: 10458801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3C2C760234 for ; Mon, 11 Jun 2018 20:42:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AF40285D3 for ; Mon, 11 Jun 2018 20:42:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DDAF285D8; Mon, 11 Jun 2018 20:42:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89398285D3 for ; Mon, 11 Jun 2018 20:42:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2500E6B0005; Mon, 11 Jun 2018 16:42:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1FF456B0006; Mon, 11 Jun 2018 16:42:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EDBC6B0007; Mon, 11 Jun 2018 16:42:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f200.google.com (mail-qk0-f200.google.com [209.85.220.200]) by kanga.kvack.org (Postfix) with ESMTP id D5F316B0005 for ; Mon, 11 Jun 2018 16:42:50 -0400 (EDT) Received: by mail-qk0-f200.google.com with SMTP id w74-v6so20482603qka.4 for ; Mon, 11 Jun 2018 13:42:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:references:mime-version:content-disposition:in-reply-to :user-agent; bh=CFXacZ8fOR7yAkurZhYhloa+JNMGX6dExHwDvgWdRVw=; b=bqLjp4KiXALJERYnd+u+ink9ODPHT3jUVa9S1fIUMi836XRJ8uuC0kDHwKKLve9Fz1 DcCEaKYqpbg7dQWNNS6NhPOkeTJhYcIAmQLU6rmxspH0mLB6CvxDDYCqmrw43lMXrX2e MJFsELXT4rBNFkjHmsB9pRMSTMVp+k5HyuhOc55hsecPLl264cL10UT4HXb1hCrmzlEm aLVDE0z7o+17QInrSYMolAJwAvtw83VQ9qaNNJOeEDK2P1CtbEuuYKmlsXnvSJ6zZaxV /JkG5xc22ih5TXM8zFcMQ30aTgxpeBn1DMjHcE9cORWOQEM8wThIl9Vube8cROKxg4Vh 2vJw== X-Gm-Message-State: APt69E0YZhzWI+R/VLGluoXHkMkKZ3dnu0t09jalsSjGccKzLBeGmHt7 ZcWw6S0O5qYE3beZuSWWOelY2CTYnRIH+PJ66b2fEcKvbB+53pG7vFLI8fAQkDcY1u5WYpAELUf CiFQE8HSVDkQLSwL6kYN89XUkz9O2MDiROae4EQSATQHrSvPgZzGCd5C62nLwJkstUw== X-Received: by 2002:aed:25b7:: with SMTP id x52-v6mr782483qtc.224.1528749770579; Mon, 11 Jun 2018 13:42:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJvquhP+EER5qzKgp+tqtCg9PAoQ8y9S2quIhclG3YAqz2VwAnjPbFmSCztDMezfHh1ITmW X-Received: by 2002:aed:25b7:: with SMTP id x52-v6mr782419qtc.224.1528749769521; Mon, 11 Jun 2018 13:42:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528749769; cv=none; d=google.com; s=arc-20160816; b=cmN/mvlEAOMpk0jRfhblrukZM0HgIuinbQX8Awg8IoDob+a7AWn7Zww3Sq3jAo89Qb xHhS9EYeIj+Z/Wcj9iO3B3sAy8LnjwK+gkqZEZ8DTvN4xovBZycbDhn1cg8WUqf55heB R7sjtVP97/CtSnruObYK449O88jakaN3R8IJwT3LvpaW5WY4FxG552edgZoUj1FuPiET cepdDLbjDozCXudxvLOLJFKDMTeNRGRe+1gXK1bvXdpc7g1l/iGgEaS0zZedwNFbKXny P5ZRi2ZUNVbqVmoQC66CfoznlMMpWKRF2UjxfYInMKxONGudXP1qt1GF0N4wgcWRSUy5 xtdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=CFXacZ8fOR7yAkurZhYhloa+JNMGX6dExHwDvgWdRVw=; b=joFK3BR3uCBuUIdIkDVlORUGTQVwr2HYuKNJKPJIiEM/S/do+SW2ug3Lw/0viYqSm9 IqJcusP7cu9tTmz/2BNJLev7LUc2V63gDl9Oo61YKdd8pK5GK5G/ZpCSezE5XuG/9XJT 5iRYqn+cShx8IfPepW27m8c1y/cwWRMvE3p+7746k4qa5USZF0hq91ywDkU0G1g4i673 S3bj7WGSrrr73HwFyHiJn1B2e1x/koYFIR1YbHYj5w4DJo/9hcZ/n0TMlfuffTdKGHjK JOu3PHaQQbAFOFKBuBfdR80LRAHWE0IOji5j6yagMTYn7nVS9FnDFrKuMfR1xe9QeYgC NUFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=N+kj0w33; spf=pass (google.com: domain of daniel.m.jordan@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=daniel.m.jordan@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2130.oracle.com (userp2130.oracle.com. [156.151.31.86]) by mx.google.com with ESMTPS id s11-v6si3506031qvb.73.2018.06.11.13.42.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 13:42:49 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.m.jordan@oracle.com designates 156.151.31.86 as permitted sender) client-ip=156.151.31.86; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=N+kj0w33; spf=pass (google.com: domain of daniel.m.jordan@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=daniel.m.jordan@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5BKftBv187122; Mon, 11 Jun 2018 20:42:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=CFXacZ8fOR7yAkurZhYhloa+JNMGX6dExHwDvgWdRVw=; b=N+kj0w33LurFUvxtcETUyjWoWn0AOjDHIzW7g0xmV8H74uN4ywI9Allj4Zp1NqwLAVsH y8ftF1EHtVrF4UApXVDfMVQ5PbxivtcAyUF4UiuLYC03EL3nSr8IBuHOcN4/qO/AmGU5 Ech0BbRQ0xeLHHBTov8dMj0GpPzurF1j2+7apyLJW/E7iwd7VKud9DRKnbSaGQVGjFls UrRNpVJWHfDnYPR8q9JVLuFLrVONVMTE2tjHOCJChovZaQdF7PS58NLMfCUYAzhBLB/F ws6OeKwx2QvF+3WXb5b6XLyKHa1dkUha+cZVBgKcyCHKlyDlvVf2TfVYxPpWUFDOo2ZL /w== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2jg6b1f5pd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Jun 2018 20:42:35 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5BKgXTG006553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Jun 2018 20:42:34 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w5BKgVD9006057; Mon, 11 Jun 2018 20:42:31 GMT Received: from ca-dmjordan1.us.oracle.com (/10.211.9.48) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 11 Jun 2018 13:42:31 -0700 Date: Mon, 11 Jun 2018 13:42:31 -0700 From: Daniel Jordan To: "Huang, Ying" Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "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() Message-ID: <20180611204231.ojhlyrbmda6pouxb@ca-dmjordan1.us.oracle.com> References: <20180523082625.6897-1-ying.huang@intel.com> <20180523082625.6897-4-ying.huang@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180523082625.6897-4-ying.huang@intel.com> User-Agent: NeoMutt/20180323-268-5a959c X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8921 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806110233 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Hi, The series up to and including this patch doesn't build. For this patch we need: 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). #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. > +#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); ? > +#else > +static inline int __swap_duplicate_cluster(swp_entry_t *entry, This doesn't need inline. 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. The rest looks ok up to this point. 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(); /*