From patchwork Fri Dec 21 00:21:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10739699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4847924 for ; Fri, 21 Dec 2018 00:21:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B477F22A68 for ; Fri, 21 Dec 2018 00:21:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A841C22BF1; Fri, 21 Dec 2018 00:21:43 +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=-2.9 required=2.0 tests=BAYES_00,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 CA37422A68 for ; Fri, 21 Dec 2018 00:21:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEB668E0003; Thu, 20 Dec 2018 19:21:41 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A9AE58E0001; Thu, 20 Dec 2018 19:21:41 -0500 (EST) 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 9AFCB8E0003; Thu, 20 Dec 2018 19:21:41 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 59C9D8E0001 for ; Thu, 20 Dec 2018 19:21:41 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id 68so3231951pfr.6 for ; Thu, 20 Dec 2018 16:21:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=yr3nmRUmlZkzqp73k8GLCYu6KE61XbncUIScYroSISM=; b=DvtX6fpd8F3SdIImchLNo3dl57hxyWvYNoruh+HSP0ioppMPxIwMKmXlzq+rwWn6p4 yF6aeMZj+uRwBKwGDn3/UbWTiEuZEO7Eg7sdOqIR7OjJf8UjxVqywCRXYMT374j9VxvT odmFXl1IQe5TXw8ZuisKUQzg4f3fV9WI07nTZHGs2FS1qQphyp0Xy5ZxKh9cU75NC9Ea B6gSwvm/qBnPz+BfZtL3+JRmN7o5KbZQZj9phVp7RhRFQH25bRijfsF6SjTm70/A+SIy l20saaYebpEed/GcENSwW1dNOUBGhq5lutTYrsY4CukPc30OIhOLD7AqiC+roiyQNWqD J/dQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: AJcUukdbDlmIVHs/Ewpa+UuU7DdjwKHmddRhjjb7VIV5j7P//gR2CCsP Iktt0sWqYKSi8iIlG4pJLC1BpGS/Td9lRv+uA1huIjE6V+qBV5Nqg7XudjCVAgPk265hszDdCwX KIeS8D2W+yDDDP11M8winHFRx1/NZ14DtsTOAU/0lnGlhlQThyh8lTD7pmLgG967O7Q== X-Received: by 2002:a63:ed42:: with SMTP id m2mr302914pgk.147.1545351700876; Thu, 20 Dec 2018 16:21:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN6voXhoFptyWxuJJwknTR58gprZ4vP/SpuhMBpo7S+bUsLiMO7KMEgrQMFZUVWnMPYxGwL1 X-Received: by 2002:a63:ed42:: with SMTP id m2mr302875pgk.147.1545351699407; Thu, 20 Dec 2018 16:21:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545351699; cv=none; d=google.com; s=arc-20160816; b=VR2fLf97Yikm4JPC/LdulByW9kbpEKIVPrfLHyRgZN+R5LwLzUA/rAjBKMj7pTm1tW bItripP9Gj5hKhqKYa19xsivkVEiuFVQAA33FovI8tnl9ZMUp4kbreXNCBWwi8xO6oDT tCjIxcvHav6np6qy6Pzo5xEFcvTaFjg0YHeZ7yUipu/3w6zpBQWfiFb5MdDz+WsNMPsI d06txbxTy0ME7jfimfMWN5cWoQCkZ7Iurp34EdOlXyd3wvySFwozcO+Xaini35zhKMaI Jep6g/CZRoducJHxWoWT5m7v+rzoq1GoZ3T5FkmYItGmhwr2vhR/PDMZce6zVG+ThuvC mCVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=yr3nmRUmlZkzqp73k8GLCYu6KE61XbncUIScYroSISM=; b=qcaAntLvNW75ZGVPO70Tkw8/GKmitH5TCTBBBdR5t7zeH24ugktjVbnkn4vLfnGiF9 ONXrN+ZzqvCJYmQ6GxjmLoyH8OiRBecgwXaYYSoLnsX0WHfjutsvOhOBypTwaw6/vav9 jejOBTzUfCz9A3o3PXBSnN2b50HIJP+Tt+D1h1xcp/wo/4TVeYbfA6xd5N2vRFknxap7 Hcr3L8H/1vy3WKiG0otIZOPCEBzSAE2n0KDXA4V8S2ykwhJVFBQjKZafOt4/rHzj/qln kmpF/RkSP4StEhF9+3FHuZud1MuYKKaynlidkMl3m8MC5BSTurah6y3MqnSYllBX7Ykr ktlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com. [115.124.30.132]) by mx.google.com with ESMTPS id a9si532980pff.126.2018.12.20.16.21.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 16:21:39 -0800 (PST) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) client-ip=115.124.30.132; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0TGGC63J_1545351679; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TGGC63J_1545351679) by smtp.aliyun-inc.com(127.0.0.1); Fri, 21 Dec 2018 08:21:27 +0800 From: Yang Shi To: ying.huang@intel.com, tim.c.chen@intel.com, minchan@kernel.org, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [v2 PATCH 1/2] mm: swap: check if swap backing device is congested or not Date: Fri, 21 Dec 2018 08:21:18 +0800 Message-Id: <1545351679-23596-1-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 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 Swap readahead would read in a few pages regardless if the underlying device is busy or not. It may incur long waiting time if the device is congested, and it may also exacerbate the congestion. Use inode_read_congested() to check if the underlying device is busy or not like what file page readahead does. Get inode from swap_info_struct. Although we can add inode information in swap_address_space (address_space->host), it may lead some unexpected side effect, i.e. it may break mapping_cap_account_dirty(). Using inode from swap_info_struct seems simple and good enough. Just does the check in vma_cluster_readahead() since swap_vma_readahead() is just used for non-rotational device which much less likely has congestion than traditional HDD. Although swap slots may be consecutive on swap partition, it still may be fragmented on swap file. This check would help to reduce excessive stall for such case. Cc: Huang Ying Cc: Tim Chen Cc: Minchan Kim Signed-off-by: Yang Shi --- v2: Check the swap device type per Tim Chen mm/swap_state.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/swap_state.c b/mm/swap_state.c index fd2f21e..ba7e334 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -538,11 +538,17 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask, bool do_poll = true, page_allocated; struct vm_area_struct *vma = vmf->vma; unsigned long addr = vmf->address; + struct inode *inode = si->swap_file->f_mapping->host; mask = swapin_nr_pages(offset) - 1; if (!mask) goto skip; + if (si->flags & (SWP_BLKDEV | SWP_FS)) { + if (inode_read_congested(inode)) + goto skip; + } + do_poll = false; /* Read a page_cluster sized and aligned cluster around offset. */ start_offset = offset & ~mask; From patchwork Fri Dec 21 00:21:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10739713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ADBA913AD for ; Fri, 21 Dec 2018 00:23:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DF7922A68 for ; Fri, 21 Dec 2018 00:23:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FC8323B32; Fri, 21 Dec 2018 00:23:23 +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=-2.9 required=2.0 tests=BAYES_00,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 2C26A22A68 for ; Fri, 21 Dec 2018 00:23:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BC5B8E0003; Thu, 20 Dec 2018 19:23:22 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 36D3E8E0001; Thu, 20 Dec 2018 19:23:22 -0500 (EST) 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 25BBD8E0003; Thu, 20 Dec 2018 19:23:22 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id D7D148E0001 for ; Thu, 20 Dec 2018 19:23:21 -0500 (EST) Received: by mail-pg1-f197.google.com with SMTP id q62so2957448pgq.9 for ; Thu, 20 Dec 2018 16:23:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=TNU0se+Grs1y/7WdT4aXrSRow208TNt2OIGVGjjs1Ac=; b=AbRyfgQCQWWdQS3xwjP+aeie7aliZSfJ+wKD+wV+VbemM87FN8Cm54S5swucPvqk02 zfGwQFanNOcB8wawM8xSlsQyMVPl+8MY+McRaICzF846HbOpYcPqGs++2e+B3LeOPy+S Dqv0YBOJhoA/UkGw4oZ6GzUokVrsoN4c1WkZ2eTZIZNpEqr6RERX1JqjICUvMR6PAbA4 oZQUmT9ExBgMbEM5u+wV2S7pfJF+6wJcRGLzlItRmaZYwkIPJ/Bsk6kzHM/SzPCZNZEJ D29pKGth//Fu+jH/lAEa/Ov+dq9SQZe0h7for4EKgNA80pWUAQggNNlu8tqsTSVGMF+c 3GEw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: AJcUukdBdxjxTFiW4zY/sreVsjlQe7/o6FTM6QIWS4BXVxwoa9NXHLK5 5T1BeBbBR8OuMydEV7OGjjRsohgUnR2a2NqeuNLChMAPG+UhVwTQxuN+yxNYdkyA2z6KXApNzia EnXBZS/sWFgMo9XA24zW6J+KFkgavFYqJuJL4RUIFUHQCloGpU9bSlqfe28QwRTMBbg== X-Received: by 2002:a17:902:f81:: with SMTP id 1mr337254plz.174.1545351801538; Thu, 20 Dec 2018 16:23:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN5tufJgbXvmmGbnmdpNY6/1rDlN/aiDgPAntjt3BhjMqtS4l3C1D17K26kau2sYwezddgDr X-Received: by 2002:a17:902:f81:: with SMTP id 1mr337222plz.174.1545351800784; Thu, 20 Dec 2018 16:23:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545351800; cv=none; d=google.com; s=arc-20160816; b=ZM7emf772GI7cWwPLl1p+EhPPj+DigzaTfEVNVxJa0JZQlPKPkEOMnFbmg6uZN0A2t iBs21WnB3AmGi2FeGp3M8Vaj8ehEPQBSC4gjVKOeuF1YHCTR+emXNAt2ymAjHabhXRmx 5GjRJjqOswYXwpN9TDR2uALH8h5PUHsZ2VdRPvsp9TzG+wSd6g8c78U2Hnjyy7t3lbiw /lZhx5DmgMW0pmEqkpOypD+z8NIP28itXJXaL0af5F7XSEcNiN/aApk/wcZP76MsiYQe UpRJLB4Hev9XHeq7ZacNvmsz9Tg2CYv6Q9WvgwrbnkZXd5y/Nug5/xFTQLdePpSvhmji 0q0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=TNU0se+Grs1y/7WdT4aXrSRow208TNt2OIGVGjjs1Ac=; b=qNcJkK9Ie8tSnegDaDD1SHqV9MwwPwQz86kBc3BkPWnLulhfI130TVJ/hzNH3lMmoO xJxxlFTFTfVefvGpmlxoRBYyf40RF7TF2dGB1hkJVASBWxUOm4rtPIgPSyuE3tlFRYyM dVIU0rPKY1GW0Z6U3LZVXBOP01dTCte6m8hNSQz9M9P71xxqGiVxoKApF+geGCTZZ0wQ zf1SLu7AXkPqAy9+SgC1E4cEzkbM1Gx+cw4iG83P+tIn4GKux1lzdlg69JIVaI9DvYvK 9n/st+pdfwKh+lZVt30bfPrV31tH9JPDAD/mdEunAtqOsrtWiqKzmMs96JpcwAN2P06a rtWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com. [115.124.30.133]) by mx.google.com with ESMTPS id r207si8462452pfc.179.2018.12.20.16.23.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 16:23:20 -0800 (PST) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) client-ip=115.124.30.133; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R801e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0TGGC63J_1545351679; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TGGC63J_1545351679) by smtp.aliyun-inc.com(127.0.0.1); Fri, 21 Dec 2018 08:21:27 +0800 From: Yang Shi To: ying.huang@intel.com, tim.c.chen@intel.com, minchan@kernel.org, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [v2 PATCH 2/2] mm: swap: add comment for swap_vma_readahead Date: Fri, 21 Dec 2018 08:21:19 +0800 Message-Id: <1545351679-23596-2-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1545351679-23596-1-git-send-email-yang.shi@linux.alibaba.com> References: <1545351679-23596-1-git-send-email-yang.shi@linux.alibaba.com> 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 swap_vma_readahead()'s comment is missed, just add it. Cc: Huang Ying Cc: Tim Chen Cc: Minchan Kim Signed-off-by: Yang Shi --- mm/swap_state.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mm/swap_state.c b/mm/swap_state.c index ba7e334..b96f369 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -697,6 +697,23 @@ static void swap_ra_info(struct vm_fault *vmf, pte_unmap(orig_pte); } +/** + * swap_vm_readahead - swap in pages in hope we need them soon + * @entry: swap entry of this memory + * @gfp_mask: memory allocation flags + * @vmf: fault information + * + * Returns the struct page for entry and addr, after queueing swapin. + * + * Primitive swap readahead code. We simply read in a few pages whoes + * virtual addresses are around the fault address in the same vma. + * + * This has been extended to use the NUMA policies from the mm triggering + * the readahead. + * + * Caller must hold down_read on the vma->vm_mm if vmf->vma is not NULL. + * + */ static struct page *swap_vma_readahead(swp_entry_t fentry, gfp_t gfp_mask, struct vm_fault *vmf) {