Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7023546imu; Mon, 3 Dec 2018 06:37:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/XPh4JLFkOEcZukDxWUKbgOPUotj0kV87yKievcrNURR4y7dzeIiF6rhf4dg8R7x+2GszsW X-Received: by 2002:a62:ce0e:: with SMTP id y14mr16774530pfg.100.1543847853640; Mon, 03 Dec 2018 06:37:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543847853; cv=none; d=google.com; s=arc-20160816; b=ISAbL3r7mRl58onMZu6wAKUQXTAY4ha9EBIM44gZGbfpfEwwZ8mXQt+B6orD/we9QC L8DTiB3Y0XDioETwQmqOMGYEkfLzf0DXv+TZO5fYdjncV948sL3ipW35PMxjYofZlK9F q9wl550B0OA/mBHzCWJLD/PwDQLXpQP9/oTmTrTJz1Oa7ALqnt9mFmDhNNt3JFoSHcBj m7L8lLOrnC6yJt9YNlt0c2yTk0NSeXRLlqnnM0RMLqAWm8qOki/623I86mYr2ukOUunV wlJWrCksmoE33zuh3jLWxaEZN7Cwht4WfFixlmv0y0gqx/3baz2moE39d48w4qh7FhP+ EiAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=kwJ49FC5FWtRYQ1LqcYvEh+IfdElL4oabQVLUlgQWc0=; b=1FjfEV/jRFk3wd4UQp8Bkm6gS2jUWiGHlExJQgjLAbM4MxI7I787Z0T8N6e0w8Ba1n /niu0SHYPqTyxvJVpsEgHFYB0X4Y0pgGEOY7RIVl9YRhWrY25SPUtflGlzs7RxHApn5+ j2MYWZjnWzrRGnBn7OZXd/rJzeJV7oNrYY4C1+PHGo3GAgfeM7ix7SnZrXQc3KowqP11 xJe4XT82uXvl4MfhrqP/KjyRW/Up1DH0ryO9zb4Wy8pJhmWQcJlDSULAaLl9so4dnp0S A9EFPllVvwL4ouSLMfZ3diRwTptCpuIPBBhmaNXl7s6/vHHT79OhScO1gulb9pdEsFlh UubQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@digitalocean.com header.s=google header.b=RxoFhi5R; 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=REJECT sp=REJECT dis=NONE) header.from=digitalocean.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8si12801716ple.329.2018.12.03.06.37.18; Mon, 03 Dec 2018 06:37:33 -0800 (PST) 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=@digitalocean.com header.s=google header.b=RxoFhi5R; 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=REJECT sp=REJECT dis=NONE) header.from=digitalocean.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726610AbeLCOgq (ORCPT + 99 others); Mon, 3 Dec 2018 09:36:46 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:39636 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725917AbeLCOgq (ORCPT ); Mon, 3 Dec 2018 09:36:46 -0500 Received: by mail-qk1-f193.google.com with SMTP id q70so7426229qkh.6 for ; Mon, 03 Dec 2018 06:35:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digitalocean.com; s=google; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=kwJ49FC5FWtRYQ1LqcYvEh+IfdElL4oabQVLUlgQWc0=; b=RxoFhi5R+eqiwEt3WWyFBsMQqTD9g9/lN5v6law9ZYAtuApWuOr0u1SXqsdqn6n29d b9slAXYIr1JXL8c+Z1vGmrXS2cc/CcrIigXzvXzKN4Z2A9hKGfc+rUZDrbM0+DOm9zlf lRsbFTU1o45vf3qgQSlOkOZ/PUyS6mkhaWhXc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=kwJ49FC5FWtRYQ1LqcYvEh+IfdElL4oabQVLUlgQWc0=; b=neXYK+2oY2kA5u6u2Sk0h32prXmpgs1l2jljiB78AahnSz6YF0ACj5i+I/JO7FyfEH +RluTc4Hzkp0azLQJx2S3kkGN6nn+avghNbz+eBCsaoyBddFeA32DbU0QQz3gNZjjjvz uYVC5MFFl0EXmBNhwqOOLUZtLzaSpO/DrkYhAtX2M6wH746mdAl8E36hEdEz0wIXUjFZ oW9+gepCNOqvHXdukQ0TUHVvTUfaGFpTQsTH6C/cNKdp125hc7Yk4kUALT/V1DkbhH5+ K6uXIF+rqmtsJQS5FePkqPPO4CIyhdGZKmW22UtpCoCcW2ZccXQV19I8chxzAdwzNyiC cvJA== X-Gm-Message-State: AA+aEWYRjsAWQxL/t6MB8IJw0TyHv1wNXsuPk7d5wCch8rgdeAWPBPf/ Uvel0CS6ECMY7aL3tE2qBMEOnQ== X-Received: by 2002:a37:8107:: with SMTP id c7mr14366785qkd.77.1543847731440; Mon, 03 Dec 2018 06:35:31 -0800 (PST) Received: from [192.168.86.60] (c-24-147-95-226.hsd1.vt.comcast.net. [24.147.95.226]) by smtp.gmail.com with ESMTPSA id w15sm8858531qta.16.2018.12.03.06.35.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Dec 2018 06:35:30 -0800 (PST) Subject: Re: [PATCH v2] mm: prototype: rid swapoff of quadratic complexity From: Vineeth Remanan Pillai To: Matthew Wilcox Cc: Hugh Dickins , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Kelley Nielsen , Rik van Riel References: <20181126165521.19777-1-vpillai@digitalocean.com> <20181126172255.GK3065@bombadil.infradead.org> <21acdf55-dbcb-1c8f-4783-9bb496dcbca3@digitalocean.com> Message-ID: <8ec7fc5f-3c14-5faa-541e-45f5b980a98d@digitalocean.com> Date: Mon, 3 Dec 2018 09:35:24 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <21acdf55-dbcb-1c8f-4783-9bb496dcbca3@digitalocean.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Matthew, >> This seems terribly complicated.  You run through i_pages, record the >> indices of the swap entries, then go back and look them up again by >> calling shmem_getpage() which calls the incredibly complex 300 line >> shmem_getpage_gfp(). >> >> Can we refactor shmem_getpage_gfp() to skip some of the checks which >> aren't necessary when called from this path, and turn this into a nice >> simple xas_for_each() loop which works one entry at a time? > > I shall investigate this and make this simpler as you suggested. I have looked into this deeper. I think it would be very difficult to consolidate the whole logic into a single xas_for_each() loop because, we do disk io and might sleep. I have refactored the code such that it much more readable now and I am using the same format used by find_get_entries. Will send out the next revision later today. Thanks, Vineeth