Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp938196imm; Thu, 5 Jul 2018 11:34:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfF18WcmwAwT1vUjzgoLQJAQSkljYS8eoPZVtjNaJJBzmSsuz9kiUHRZ7ooK52acrbZE/UZ X-Received: by 2002:a63:ff21:: with SMTP id k33-v6mr540201pgi.38.1530815688137; Thu, 05 Jul 2018 11:34:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530815688; cv=none; d=google.com; s=arc-20160816; b=Npl0rUJzhHyJThmOr1Dn6yh2PQ13T6y6q6ysxoAQDJfc5LB7/jCrpOn412cZjEbUfT H455waVc8hXkEBo7adVRk/x2GhtuYcfn6ZwVbBR4F+nsCAoavn1rtgbGI/XTcQ0F47fK jgG9sHq4HMFyfDUCImObC9Coogs7Pm4ahbWK8xu+4hSesxF7ghPV4eYHXshEJRKVbk1U vZsTpeXrwWDoZddvGjJzhlMPgE4VP3rAe+IPLwxOra0M5P0I2PrsMmrfwptMd9sT1EL6 O9O0Z7IvA8QFmfk9GKvBhiU5Mn1RTFpGhnu23wnGPP6s+yQUsnWBhFb8oaGIVQCkNfs0 WD7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=LOAd6i1mtA6nLYTSEQwVjoZS/vScMO7HFCSBMYNzhlo=; b=KOwXLRzCtuYo6gyMNfcXHhjqdkPrdCod9ab8iHkwvP4jZ8xRp/K3pcKRX9D1EFfB6v B4r4DkdufpbPpOSbrijDH5jVLYoBSrXQvfLCG8i3/dbVx49YU2OV/XWsVSrro70DB354 nqIiAeXrDPEFgCvNbyLaa5Lauh5YiVkF4PcUpZKAvpvwfbLeMgebB5RkYHNWw2bh9fYH X6Ts6Ft9r2FwOWZubnftpBCIV3bKtPn+ld2a4kpGC6pQ923AgyhHAEvRZAhvqi0D6sbI wkj5kpAk1TxvxArMCB4TxSnBS+o0PDAfh0ExcBfyN1ascJErYS4YqfjPysnafZdjqaJR erhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=fLhqUOwK; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6-v6si6196153pgk.597.2018.07.05.11.34.33; Thu, 05 Jul 2018 11:34:48 -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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=fLhqUOwK; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753910AbeGESdz (ORCPT + 99 others); Thu, 5 Jul 2018 14:33:55 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:43184 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753807AbeGESdy (ORCPT ); Thu, 5 Jul 2018 14:33:54 -0400 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 w65ITTH3006912; Thu, 5 Jul 2018 18:33:20 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=LOAd6i1mtA6nLYTSEQwVjoZS/vScMO7HFCSBMYNzhlo=; b=fLhqUOwKRFlU0av8ISChzxh+4Wkk8tM1tfvE+WAyFcCakUWIjWqN+8rsNiDpFSL+TxCx mbP8aoUH5t4ZoPFBoyY4RU5/LnNM7AZhYcL735Zrq7RP6qVFrrxh78auAwTdaIe55gCB wK8Z79IoQUSF8epn4dpE8LQVZcdUGx+gpzR+9FEZ4kUESnOjUv1sdTvaVP7drnjfxKRr vvAuxnH1rKUO2aOPdH8ZMXr9AOpF20nYzsGqppUarm5P03571iObQ9IKowmylZSFN7vY wFnpbvcdMN2WxX/Cs2B3PZbtbNNP3pMDOaduIdfY6jthVwTxJ9WSTxIb2QQ8mHLjigRM ng== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2k0dnjq2mx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jul 2018 18:33:19 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w65IXHGs001474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 Jul 2018 18:33:18 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w65IXFQu024030; Thu, 5 Jul 2018 18:33:15 GMT Received: from ca-dmjordan1.us.oracle.com (/10.211.9.48) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Jul 2018 11:33:15 -0700 Date: Thu, 5 Jul 2018 11:33:18 -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 -v4 05/21] mm, THP, swap: Support PMD swap mapping in free_swap_and_cache()/swap_free() Message-ID: <20180705183318.je4gd32awgh2tnb5@ca-dmjordan1.us.oracle.com> References: <20180622035151.6676-1-ying.huang@intel.com> <20180622035151.6676-6-ying.huang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180622035151.6676-6-ying.huang@intel.com> User-Agent: NeoMutt/20180323-268-5a959c X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8945 signatures=668704 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-1806210000 definitions=main-1807050206 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 22, 2018 at 11:51:35AM +0800, Huang, Ying wrote: > +static unsigned char swap_free_cluster(struct swap_info_struct *si, > + swp_entry_t entry) ... > + /* Cluster has been split, free each swap entries in cluster */ > + if (!cluster_is_huge(ci)) { > + unlock_cluster(ci); > + for (i = 0; i < SWAPFILE_CLUSTER; i++, entry.val++) { > + if (!__swap_entry_free(si, entry, 1)) { > + free_entries++; > + free_swap_slot(entry); > + } > + } Is is better on average to use __swap_entry_free_locked instead of __swap_entry_free here? I'm not sure myself, just asking. As it's written, if the cluster's been split, we always take and drop the cluster lock 512 times, but if we don't expect to call free_swap_slot that often, then we could just drop and retake the cluster lock inside the innermost 'if' against the possibility that free_swap_slot eventually makes us take the cluster lock again. ... > + return !(free_entries == SWAPFILE_CLUSTER); return free_entries != SWAPFILE_CLUSTER;