From patchwork Mon Mar 18 00:02:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 10856707 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 5D9BA1575 for ; Mon, 18 Mar 2019 00:03:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 470842919A for ; Mon, 18 Mar 2019 00:03:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AF472922B; Mon, 18 Mar 2019 00:03:33 +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,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 B7CE72919A for ; Mon, 18 Mar 2019 00:03:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 28B746B0006; Sun, 17 Mar 2019 20:03:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 23ABE6B0007; Sun, 17 Mar 2019 20:03:30 -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 102626B0008; Sun, 17 Mar 2019 20:03:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id E1BF86B0006 for ; Sun, 17 Mar 2019 20:03:29 -0400 (EDT) Received: by mail-qk1-f199.google.com with SMTP id o135so13293827qke.11 for ; Sun, 17 Mar 2019 17:03:29 -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:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=D6RBo2xA005T3vgh61b+8gQHpH8S5KLC0eS56YqC/3o=; b=BCuqYNZ5AyXzFwaxCpPbetv/pC95tHars0GhCreb0OT2BirZZQv1rBKtm6AC2m6bcY Mr1CXKKtdWC2A7QR6fJ+J7vNFDy3oCWS+MLyIZQiQAfJBMWo1qXDPiImnrBp93zPwDcM TPBiOW9kGRkwQOaZvigpHX44ds70iB4cc/OtwUzdjbEP3E8thEz1KbeN3hTGNHGq/x8V nJ8wkxkL15Hv82ayOk2l246VDPZgfgADvPz6Heg1sD0UWVnmMg+UiNEQ4DEx5ODj0oWd Wh/DR2ZkIddvYxW//kTRdY5i9ARkftG+i489reoUqCw80e4g12j/9YZvi/UhTThVBIQd ZaxQ== X-Gm-Message-State: APjAAAW5xmNwPTb3PU/Dlj0v7rXrVAWklXMSBtn5akkKwht89NuwkVzU V4AU7nc2Xsnocq0dkN/Qw8fIGtBntSbf3P6vb/UMdEX5Z5Yv13xF02KI4mDHeBGNJeO41n5ne27 FQjUHWyp0mpFIthAktddfXA2PeaUupjc4eZ2uzKYRkN4BnTzWnj81bu2OVWFTFC4= X-Received: by 2002:a05:620a:1428:: with SMTP id k8mr10433998qkj.185.1552867409671; Sun, 17 Mar 2019 17:03:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRq0Nk4C1Oqx8oEHbLHcKNaG1j4mdIBpd4zPrBDTkkSMik2dB2czs0a4RsrH9EfnI1Ff/t X-Received: by 2002:a05:620a:1428:: with SMTP id k8mr10433949qkj.185.1552867408474; Sun, 17 Mar 2019 17:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552867408; cv=none; d=google.com; s=arc-20160816; b=N2cG1oPeP9/eTmOhVup/jY3pUHqSAEXRAdfsplKJT9lYDaMZTHLl8rPhvStR++XTrg zEM0jzGluC+mwdxamxzL1xQFGioz8RMn7Y6MJBt4/NWorQnccfJ+eiQvDJc+T5nfnNAM NPu9JpBkon3BC/Mf+cAdJYZlPOFEIUMsHPsGv5iyaibvyfgebQmzrrofsSSA0TcYAOSe 68SKaGe2LmeRMK44zAAcLfo8z0WImV8Lp30zJhx0T+bmkPVncE5tzMeCTp22tyW7XL6R cLDgXarpGZMafO+J8NiWQroVg/kpAZ9k1f+PCuQskx3srpPW2GeExVCE84GLV3F/Z9Ba n38g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=D6RBo2xA005T3vgh61b+8gQHpH8S5KLC0eS56YqC/3o=; b=pyBlZa/Tu+FGu54Ihe2pk2e0mzAaYYiKWbDaLo6+AGSgvWCwGa4Znf/DpFjl2EmYPX S0ac+PcIhs/EyS4IlSwJq2+l646z9imSxsG66nmxTTdoKyF2JOBx/insw4KCum/eHKEZ RC0ns3zzjFxRpluEi6SABRicJzf/R/oFpbUVJfQsPFJ78d6CdFqbB6pac41vv4Pp46PT KwT2YRnLRiucP9l5mm4f2Uk8LZbv5CHgBBw/czsFD78AP/gb8EI4lPPdId++TgX9JQR8 xNAxxCjFBtevEHOxUnA5B+FeNx9i0ICTLHcQPHO3D9/8YXB4uQCTx9sKMnB5LDKoPIJm 6MNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=n7HcCJVl; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com. [66.111.4.26]) by mx.google.com with ESMTPS id v7si3130300qvf.147.2019.03.17.17.03.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 17:03:28 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) client-ip=66.111.4.26; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=n7HcCJVl; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 36FB1219FE; Sun, 17 Mar 2019 20:03:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 17 Mar 2019 20:03:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=D6RBo2xA005T3vgh61b+8gQHpH8S5KLC0eS56YqC/3o=; b=n7HcCJVl z+T1Vd7yrPsV+pLmEJ2EzKDt5uUqwV/vOS5GsWwjehaxoSolfo4W67dv9DOWQPgO tYCwPjAKv6oqC4PPRuDJuZbIgk55DuKtSar4a3BJv4s+BvqipULukbB4/6r8XXpp 9dMxb3UlP3hnc3+PGQqhywF0q2+sNBJlMIfrLgTO/N0817TyyfU1ZylhMbtrdAdJ 6C809TxyfrsoQVCeFwQfVuQPXbpz+6lZCIz2hOOzgYk9COv0ZmOgGwuhN30EBpF1 7g9PAuYWVe8iOPfqW4Vx3zRwNeEQFw2bl8sScdDgyu48/YA2OVxhnXvPS+C6iTfG gplnsEBPzVMMMA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddriedtgddukecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhn ucevrdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkph epuddukedrvdduuddrudelledruddvieenucfrrghrrghmpehmrghilhhfrhhomhepthho sghinheskhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from eros.localdomain (ppp118-211-199-126.bras1.syd2.internode.on.net [118.211.199.126]) by mail.messagingengine.com (Postfix) with ESMTPA id BEB2DE427B; Sun, 17 Mar 2019 20:03:24 -0400 (EDT) From: "Tobin C. Harding" To: Andrew Morton Cc: "Tobin C. Harding" , Roman Gushchin , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/7] list: Add function list_rotate_to_front() Date: Mon, 18 Mar 2019 11:02:28 +1100 Message-Id: <20190318000234.22049-2-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318000234.22049-1-tobin@kernel.org> References: <20190318000234.22049-1-tobin@kernel.org> MIME-Version: 1.0 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 Currently if we wish to rotate a list until a specific item is at the front of the list we can call list_move_tail(head, list). Note that the arguments are the reverse way to the usual use of list_move_tail(list, head). This is a hack, it depends on the developer knowing how the list_head operates internally which violates the layer of abstraction offered by the list_head. Also, it is not intuitive so the next developer to come along must study list.h in order to fully understand what is meant by the call, while this is 'good for' the developer it makes reading the code harder. We should have an function appropriately named that does this if there are users for it intree. By grep'ing the tree for list_move_tail() and list_tail() and attempting to guess the argument order from the names it seems there is only one place currently in the tree that does this - the slob allocatator. Add function list_rotate_to_front() to rotate a list until the specified item is at the front of the list. Signed-off-by: Tobin C. Harding --- include/linux/list.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/list.h b/include/linux/list.h index 79626b5ab36c..8ead813e7f1c 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -270,6 +270,24 @@ static inline void list_rotate_left(struct list_head *head) } } +/** + * list_rotate_to_front() - Rotate list to specific item. + * @list: The desired new front of the list. + * @head: The head of the list. + * + * Rotates list so that @list becomes the new front of the list. + */ +static inline void list_rotate_to_front(struct list_head *list, + struct list_head *head) +{ + /* + * Deletes the list head from the list denoted by @head and + * places it as the tail of @list, this effectively rotates the + * list so that @list is at the front. + */ + list_move_tail(head, list); +} + /** * list_is_singular - tests whether a list has just one entry. * @head: the list to test. From patchwork Mon Mar 18 00:02:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 10856709 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 5E5BC1575 for ; Mon, 18 Mar 2019 00:03:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 480CC2919A for ; Mon, 18 Mar 2019 00:03:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C1932922B; Mon, 18 Mar 2019 00:03:36 +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,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 B85072919A for ; Mon, 18 Mar 2019 00:03:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76C0D6B0007; Sun, 17 Mar 2019 20:03:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 71FCF6B0008; Sun, 17 Mar 2019 20:03:34 -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 572556B000A; Sun, 17 Mar 2019 20:03:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 2A8B86B0007 for ; Sun, 17 Mar 2019 20:03:34 -0400 (EDT) Received: by mail-qk1-f198.google.com with SMTP id y6so13445516qke.1 for ; Sun, 17 Mar 2019 17:03:34 -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:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=AeBIbLH/k+PlVuOhUlPjQBBvHXf9fNsgIcyOzJV+yJ0=; b=nOh1tsgp5VK4/ETA2MnTogP5Pey4PsSpWHtqYpu8zmH+41nKQFtd2+vVYZ9tixkd1E NDsarmLAiwKffKi6TKjJw8wUlfj6iqrnf9RASWCOBJ4ilIsuNkV3xus9VSnG417zU4MA TBlyH7+LSoLdYnn6G5VXetqs4mZZPNM6Xqfc6ZkDrCKmeoXjohSaZyOCR67SD4PbsW76 +l+oD4GBgiKQCmbRXJ1+eoeLrTtf/Gzd0jfW+BCVKTbfC5A47yvtXR48FXHgMyRCp+/k U5G6ha1zSOu45iVqlXhTNUWnA0YkIqH3koUn/Cw/ZpLqgxhhCN19jy58wjjaSbby+Eqt PdiQ== X-Gm-Message-State: APjAAAUDQRTZbmrAHe1t6UrzuXJhK5KcxBAka+EARik+daBf2q4cHAWI 5uhHKhGqNfuB2XB9JUYXrWqbkEQqImsriIsVHaxuDojcY9/OgleKJKgR6SH7RYzdxDNmAwcsjUI MWbiQhJ/PKz9eugQ3jf1WtnVRS0prxOmyxNnMX4+whmyXkO6JFNK0j5LA58P6yjs= X-Received: by 2002:a37:a650:: with SMTP id p77mr11158032qke.256.1552867413917; Sun, 17 Mar 2019 17:03:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyytxd1cVgQjQFXYdK8rVAQkzicV78MiWB8vRhP1v3dS3VEbIMXWy8CmjilmjuOZeU+BqDs X-Received: by 2002:a37:a650:: with SMTP id p77mr11157988qke.256.1552867412746; Sun, 17 Mar 2019 17:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552867412; cv=none; d=google.com; s=arc-20160816; b=oHt0LQG0mA5i2KyFTGLp9jwwo+kqtM8FrH+cVqWXdTmJeg07qHBsEtRL955+RWDsLu 3Ipw6rtRHQf9+ipY7Xf/C1u6DcwLHFFsuxNfJeSAqznHoA8rOVh9nZx/gjfwbc9SzFtn J1ibj2M2TA/w7DL2NDnRNjwIQpiNgJgMUOvH+cvtV9RktDMduBR9opvAgzCH4V6pgAf2 E8MShL30rESnvxmZmb3tLz55yLT+LqG8UAI/CVsHJub0uU9vn7bedYs/2/k8R0z4057W nP1NcKPHyeESuB0wI14N36qQwx+K63YIhN684/m8Ift89vd6UAe7UKyGLk3+S03VcuRw uiSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=AeBIbLH/k+PlVuOhUlPjQBBvHXf9fNsgIcyOzJV+yJ0=; b=rjRUW4rvLZr3pHpiC+ZSjIOv3WMAkbNwXBEoa0Ypk6/bd4dvnZCnc3p5DwZ5CXlQJr EhcGX1sY/7soLb8G+NLCx8LezkiuJixyXyJ1PTHioA1bQUkK4i22oar1pGA8VunJspVU dKcEvBbZfPXOS+a5pSh1iI3guixeqiLeuvuMhiMIfg/RzN04lMZbN/Z4Mq1yjPMzYE9o K94HSfdft8ZGscVZQm9BpOJewH1WIhz5EvLFQQUvQF8+9Sp8k7yJB98mbtF1WlsMb4w2 gD8KhG7w1/DtSGNdb5Ig6dVJ4Gk7Ej4eoVTMqqWbthta54k7IcD1FnUcX6NiYZgbW5nE Wr2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=ssQMkIrB; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com. [66.111.4.26]) by mx.google.com with ESMTPS id c36si659431qtd.352.2019.03.17.17.03.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 17:03:32 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) client-ip=66.111.4.26; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=ssQMkIrB; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 62E7C2144B; Sun, 17 Mar 2019 20:03:32 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 17 Mar 2019 20:03:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=AeBIbLH/k+PlVuOhUlPjQBBvHXf9fNsgIcyOzJV+yJ0=; b=ssQMkIrB shXlcEPj1zP9UfU1fj0Oei9LBB0KeFE5A3iLgetR/WeVzb7Ui21UYJCUEt/zlmyG WD+edggAXX3g68bBpYjxNFFBekbcOljvZy1iIUd+Z8skU7tkqfeyUjng+GXNk4lT jskjvl50U/HHP/3WcEZjXUJIgDuMc/ua5bdMAWtuZ1uXKq5IqRyk6nde71StXtfy ghb3gact3LCB5wqjHC6BA9oniV0WxEGb9q9Qkk5iTk4k9kg1S3xJ6gJmguAlMSNd +4Q4XgEIglaNd+Iz3fS5hwxHkd7WUsO5lMJ46EbLXWSCrG29lXXLgj02j7S4mC2Z sjB1xFsQInYrrQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddriedtgddukecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhn ucevrdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkph epuddukedrvdduuddrudelledruddvieenucfrrghrrghmpehmrghilhhfrhhomhepthho sghinheskhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from eros.localdomain (ppp118-211-199-126.bras1.syd2.internode.on.net [118.211.199.126]) by mail.messagingengine.com (Postfix) with ESMTPA id E5B9CE4581; Sun, 17 Mar 2019 20:03:28 -0400 (EDT) From: "Tobin C. Harding" To: Andrew Morton Cc: "Tobin C. Harding" , Roman Gushchin , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/7] slob: Respect list_head abstraction layer Date: Mon, 18 Mar 2019 11:02:29 +1100 Message-Id: <20190318000234.22049-3-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318000234.22049-1-tobin@kernel.org> References: <20190318000234.22049-1-tobin@kernel.org> MIME-Version: 1.0 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 Currently we reach inside the list_head. This is a violation of the layer of abstraction provided by the list_head. It makes the code fragile. More importantly it makes the code wicked hard to understand. The code logic is based on the page in which an allocation was made, we want to modify the slob_list we are working on to have this page at the front. We already have a function to check if an entry is at the front of the list. Recently a function was added to list.h to do the list rotation. We can use these two functions to reduce line count, reduce code fragility, and reduce cognitive load required to read the code. Use list_head functions to interact with lists thereby maintaining the abstraction provided by the list_head structure. Signed-off-by: Tobin C. Harding --- mm/slob.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/mm/slob.c b/mm/slob.c index 307c2c9feb44..39ad9217ffea 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -268,8 +268,7 @@ static void *slob_page_alloc(struct page *sp, size_t size, int align) */ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) { - struct page *sp; - struct list_head *prev; + struct page *sp, *prev, *next; struct list_head *slob_list; slob_t *b = NULL; unsigned long flags; @@ -296,18 +295,27 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) if (sp->units < SLOB_UNITS(size)) continue; + /* + * Cache previous entry because slob_page_alloc() may + * remove sp from slob_list. + */ + prev = list_prev_entry(sp, lru); + /* Attempt to alloc */ - prev = sp->lru.prev; b = slob_page_alloc(sp, size, align); if (!b) continue; - /* Improve fragment distribution and reduce our average + next = list_next_entry(prev, lru); /* This may or may not be sp */ + + /* + * Improve fragment distribution and reduce our average * search time by starting our next search here. (see - * Knuth vol 1, sec 2.5, pg 449) */ - if (prev != slob_list->prev && - slob_list->next != prev->next) - list_move_tail(slob_list, prev->next); + * Knuth vol 1, sec 2.5, pg 449) + */ + if (!list_is_first(&next->lru, slob_list)) + list_rotate_to_front(&next->lru, slob_list); + break; } spin_unlock_irqrestore(&slob_lock, flags); From patchwork Mon Mar 18 00:02:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 10856711 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 913531575 for ; Mon, 18 Mar 2019 00:03:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A5A72919A for ; Mon, 18 Mar 2019 00:03:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E65E2922B; Mon, 18 Mar 2019 00:03:40 +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,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 D80392919A for ; Mon, 18 Mar 2019 00:03:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C9E636B0008; Sun, 17 Mar 2019 20:03:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C4CD96B000A; Sun, 17 Mar 2019 20:03:38 -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 B143F6B000C; Sun, 17 Mar 2019 20:03:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by kanga.kvack.org (Postfix) with ESMTP id 91CDF6B0008 for ; Sun, 17 Mar 2019 20:03:38 -0400 (EDT) Received: by mail-qt1-f200.google.com with SMTP id b1so14801635qtk.11 for ; Sun, 17 Mar 2019 17:03:38 -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:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NJ63LCCLaSV3iAE8Jn20nHVAI3AvEK5t29Xi1XCFI+c=; b=WzXEDA6v67CTJvUY5VQkJiMnQHCEVQ1mP7o0Qj1JhW8mkmsYMwNvz1BJd+PSRb+ZbY RPPCKcqDdgnPIeRgL38WqcST9ceOWm4HWb/2PlfGi4ZASe0V8HtDYGoD2Q/sxY5Lpyv5 5CwwGUNqKxFwp0YKGhidZJh7EzjnUiknUtgjKyJ7Cy5D5m5DbLNKrYg+ypJuGS5W6++Z iVZC4X5g6PG21MD9+fREV2v5uhIqw/EDPJ1b8x6FO7DiD80aFeUe64uc1j/6NGmii+Bt +xoIWz3v/fhmEjX+NaUUyUbn9W3bA+RFs5YynxyLSE+lNpbzPBNTxhUeRWAZKA/Kecot ugaA== X-Gm-Message-State: APjAAAUWwqCXv4ZqAAUXgrGpuVYMAb0ADyRwm5W9bkMYgCic/RwBGu8U TYrKqIIWBZMnc7SsnvTUV9bkNEQ06JKnSQZ4AQL5OE4JmaX60lGZUhHCal4YfBowOO7solt44fQ HUT2UU19Wk3K2QHFDrrmWNjNQ1ABWv9j6EbisgYvb6KbckGtSgaUjfX0DhRVv4Zw= X-Received: by 2002:a0c:9599:: with SMTP id s25mr3417455qvs.119.1552867418273; Sun, 17 Mar 2019 17:03:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxuCk5jjXt6e44q1guBFndnjupGXeIZvoarDgiVnoWBnevqEgz09EcB8a+Y9Imv4+1if1Ha X-Received: by 2002:a0c:9599:: with SMTP id s25mr3417386qvs.119.1552867416810; Sun, 17 Mar 2019 17:03:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552867416; cv=none; d=google.com; s=arc-20160816; b=C8cFQaSsjLMhCQGF3/HnATrv1wjbzHtL6G/x0z4VDv4dVOHtY3X5kB6GOELCbDygks IB287EOP5tECJh6vlb8B5hI0MNo6Sox3cUcPSuZoGDtBCXdvUTvotbeCLLZ0ybQEW3iN nDf37VR9YiPh9Sz9JzUIS0gouWDI5i73qZ1Jenu1crC3F4xtkQ4rtUtDFrF0DH4zMolC zX3kpB2BgMFHHyati7r9AJXEkB120lNDPexjsSW5TCuGfpJIAYXdjkNXm38G6i+CmyQS hF5dlzURrQzGlqKu6w7klcqQ+b4WC9dyTgDydaFV+Mnfd3WtPc3VjQkWo6ZfkbupKME+ Oyjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=NJ63LCCLaSV3iAE8Jn20nHVAI3AvEK5t29Xi1XCFI+c=; b=DTIdo3cJpMClxxGhHusA9BwxuEtLv1WlzANVemVFJ31zDPrM8Ujs+0YpH69wP0Yf99 q3D4KcGMxlxXKG9ESg00Ru/dpy1K7BlDHLSakL9FFtJxF9kyDA60XjSkF0o4PaebvahH SaYNy/Mrj5kolSof5Ech8TEqY5ObAXMrJWWrd+WrDAqFW06mvhq9eb+z4bZfg1oVBxTR +xR1rtbRCrFmIpEoC1j4qk399NwhCDypFsWCI7V8/MGc9wRU7ZgtsUh/wRD4a0s8SDgZ T0PoANcB1whJ1J45HgY1BCN6pmKpTBXzutcNLHnExfKXxYtLwuNMhCS90pOR/fEh9bfZ OOjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="pCd6G5/s"; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com. [66.111.4.26]) by mx.google.com with ESMTPS id u69si5208197qku.123.2019.03.17.17.03.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 17:03:36 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) client-ip=66.111.4.26; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="pCd6G5/s"; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 85C5621B74; Sun, 17 Mar 2019 20:03:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 17 Mar 2019 20:03:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=NJ63LCCLaSV3iAE8Jn20nHVAI3AvEK5t29Xi1XCFI+c=; b=pCd6G5/s IXk6xU7bwSgPoncwBnY1rz9JSIIm3jsaPiDopQmEidYawkMK7P22Yrh69Lic82j/ u29QWAJD0OVZ8ushlWC8j0Thl3bkX5t5WMeaBnvCjqgMG+E5CyUJceEHcgUch/vc tGUIA62xBGG942nyd9+f6PSF8ZrshTW04TVDPINKTivdbCeH671z63whT70e3tZQ OFKz+eOKCFkdaMKaOaT8BgDbV8il3f5757Pc/kv+n9BUVWTWnS6qYJJ2lMn6XMaG A5FK8BG9a9aIruxIjUYNEreotCLHsdRrgUlBLVcPCUitvd1X+ocgIvRp8y9YQ50a JmqbHTnrplbvdA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddriedtgddukecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhn ucevrdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkph epuddukedrvdduuddrudelledruddvieenucfrrghrrghmpehmrghilhhfrhhomhepthho sghinheskhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgepvd X-ME-Proxy: Received: from eros.localdomain (ppp118-211-199-126.bras1.syd2.internode.on.net [118.211.199.126]) by mail.messagingengine.com (Postfix) with ESMTPA id 1A615E427B; Sun, 17 Mar 2019 20:03:32 -0400 (EDT) From: "Tobin C. Harding" To: Andrew Morton Cc: "Tobin C. Harding" , Roman Gushchin , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 3/7] slob: Use slab_list instead of lru Date: Mon, 18 Mar 2019 11:02:30 +1100 Message-Id: <20190318000234.22049-4-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318000234.22049-1-tobin@kernel.org> References: <20190318000234.22049-1-tobin@kernel.org> MIME-Version: 1.0 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 Currently we use the page->lru list for maintaining lists of slabs. We have a list_head in the page structure (slab_list) that can be used for this purpose. Doing so makes the code cleaner since we are not overloading the lru list. The slab_list is part of a union within the page struct (included here stripped down): union { struct { /* Page cache and anonymous pages */ struct list_head lru; ... }; struct { dma_addr_t dma_addr; }; struct { /* slab, slob and slub */ union { struct list_head slab_list; struct { /* Partial pages */ struct page *next; int pages; /* Nr of pages left */ int pobjects; /* Approximate count */ }; }; ... Here we see that slab_list and lru are the same bits. We can verify that this change is safe to do by examining the object file produced from slob.c before and after this patch is applied. Steps taken to verify: 1. checkout current tip of Linus' tree commit a667cb7a94d4 ("Merge branch 'akpm' (patches from Andrew)") 2. configure and build (select SLOB allocator) CONFIG_SLOB=y CONFIG_SLAB_MERGE_DEFAULT=y 3. dissasemble object file `objdump -dr mm/slub.o > before.s 4. apply patch 5. build 6. dissasemble object file `objdump -dr mm/slub.o > after.s 7. diff before.s after.s Use slab_list list_head instead of the lru list_head for maintaining lists of slabs. Reviewed-by: Roman Gushchin Signed-off-by: Tobin C. Harding --- mm/slob.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/slob.c b/mm/slob.c index 39ad9217ffea..21af3fdb457a 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -112,13 +112,13 @@ static inline int slob_page_free(struct page *sp) static void set_slob_page_free(struct page *sp, struct list_head *list) { - list_add(&sp->lru, list); + list_add(&sp->slab_list, list); __SetPageSlobFree(sp); } static inline void clear_slob_page_free(struct page *sp) { - list_del(&sp->lru); + list_del(&sp->slab_list); __ClearPageSlobFree(sp); } @@ -282,7 +282,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) spin_lock_irqsave(&slob_lock, flags); /* Iterate through each partially free page, try to find room */ - list_for_each_entry(sp, slob_list, lru) { + list_for_each_entry(sp, slob_list, slab_list) { #ifdef CONFIG_NUMA /* * If there's a node specification, search for a partial @@ -299,22 +299,22 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) * Cache previous entry because slob_page_alloc() may * remove sp from slob_list. */ - prev = list_prev_entry(sp, lru); + prev = list_prev_entry(sp, slab_list); /* Attempt to alloc */ b = slob_page_alloc(sp, size, align); if (!b) continue; - next = list_next_entry(prev, lru); /* This may or may not be sp */ + next = list_next_entry(prev, slab_list); /* This may or may not be sp */ /* * Improve fragment distribution and reduce our average * search time by starting our next search here. (see * Knuth vol 1, sec 2.5, pg 449) */ - if (!list_is_first(&next->lru, slob_list)) - list_rotate_to_front(&next->lru, slob_list); + if (!list_is_first(&next->slab_list, slob_list)) + list_rotate_to_front(&next->slab_list, slob_list); break; } @@ -331,7 +331,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) spin_lock_irqsave(&slob_lock, flags); sp->units = SLOB_UNITS(PAGE_SIZE); sp->freelist = b; - INIT_LIST_HEAD(&sp->lru); + INIT_LIST_HEAD(&sp->slab_list); set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE)); set_slob_page_free(sp, slob_list); b = slob_page_alloc(sp, size, align); From patchwork Mon Mar 18 00:02:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 10856713 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 5B0521575 for ; Mon, 18 Mar 2019 00:03:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 422D22919A for ; Mon, 18 Mar 2019 00:03:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 341762922B; Mon, 18 Mar 2019 00:03:49 +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,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 7A6D32919A for ; Mon, 18 Mar 2019 00:03:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 793D16B000A; Sun, 17 Mar 2019 20:03:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 742ED6B000C; Sun, 17 Mar 2019 20:03:47 -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 630F26B000D; Sun, 17 Mar 2019 20:03:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 3808C6B000A for ; Sun, 17 Mar 2019 20:03:47 -0400 (EDT) Received: by mail-qk1-f199.google.com with SMTP id l10so11146114qkj.22 for ; Sun, 17 Mar 2019 17:03:47 -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:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3DA8U0JuAXup7ms+uinV4GHOJ8keBBsE3LMsYr877sE=; b=iz4hb4f6hJd5Ox1WEQljurl3VUA2Eyyzs2Z/ZGBPQi/iJzrGjUsAmN1s5t2Ge6sUpe h7Ae8Y29tE7jUCpE6KtbpeEtG71e2oDJ78ioIOyG1q+gnv2c/13rQfU6kI5rY/RFTRXW YGv0oqoyVkiNyeDv7ggsg9/uYmN6ZfJ6iFshXwhT/Vpg5irRc2r3gtAXoemyX1GcEdoo 05z8VqJhf5c3JJKQObTLcUjsSeH4dWwm0V1iH5mDuNIIWj8or0XKVZWjMBW6WD8JYsBd 2C2bzOV7R6FbMDbDk6Z2SaesnwriMyaSqMaqP8NumqNy8RM3dXfN82C4SAF7cGNLrh41 JfGA== X-Gm-Message-State: APjAAAXcP1zP9D6nP68eLSChNlxwF97QYMsF0ckyLcIznJhfkfKyO4uY lrVc6pzS7eVG92i3LCaoQ5wJ2lHIWdpjvlaOmuguqBF2uCO6WRhuUAhuJcn3X79uBGbj2CYA85l UIigP4eX4m+KF6NXnxsqz5UPoZEGnk13lAz1XnAa8yH+UELlJZ7k71zq8s57TR/c= X-Received: by 2002:ac8:7513:: with SMTP id u19mr11961561qtq.202.1552867426969; Sun, 17 Mar 2019 17:03:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfLUCvdkAkgRP2BUQPUXIfhjrQSS68pHmPL0Zj1P4G+MeqCXQS9UTXRXogfNB2tUrGm9I2 X-Received: by 2002:ac8:7513:: with SMTP id u19mr11961497qtq.202.1552867425553; Sun, 17 Mar 2019 17:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552867425; cv=none; d=google.com; s=arc-20160816; b=fJRXPrnI5upIr+RAuKgosRNn7kQleFVKelZDc1UAi2vydKhenSVv5VB1yJS7nAaB0Z 3v4OIY78/JqSX3Po9fWiJr6ihnIgRjVKV/zSNP1JitIsLCX009/hviQvv3eWkwi7st3a XwHdtsmO4tx6BkYGZ92sAm70BGsB9D+xgMcVQ/GCuDNuMllu3f/MJeYTRDnmwKIpkIIr +dNRA7idajJM6AoHP9FCMN8rl5SoG0rYdt+BZPdIHtNO0mIOYNWrQqMchbOmiEQdr+hj jb2/F6y0cAaTsuC1MPAAWcP4fr982nYDj9J1P4iTACiKiA8IYni6hs4UlmlErOhdnpRc /N5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=3DA8U0JuAXup7ms+uinV4GHOJ8keBBsE3LMsYr877sE=; b=jVfW4bWet1a+RuDbv5F7WtmQfoJKkZA0SpbRzKYRPtKPoxDHvvBzkDJaSY2Ds3b1N3 Ji2imLA6E1fg51eLii6JmzNg5Kh4W3l2OR1AEg1+nj2joCA4vzreUtnOVaY/JzeLlCLG pvIrFxmpkSjX8lx1IpELdW0S45VHUz0k1C50oJIld7CWelfA8taB/2rUxtVx8VgSj1YG z+oDayYPzQRXYVkqnD7tWngqBgQTZeL2IoinOREccHZVvinbDj0ED6+XCOVKPjrVnKuc QSU/5c5VkgnvNaJrvGAmdHsVWFeEbQDAsGn06UrToz30Pz++8ehaFxisXtr+GwO4Ecio bfsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Pn+r46lj; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com. [66.111.4.26]) by mx.google.com with ESMTPS id d16si1180308qto.126.2019.03.17.17.03.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 17:03:45 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) client-ip=66.111.4.26; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=Pn+r46lj; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 4919521B88; Sun, 17 Mar 2019 20:03:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 17 Mar 2019 20:03:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=3DA8U0JuAXup7ms+uinV4GHOJ8keBBsE3LMsYr877sE=; b=Pn+r46lj QPFt2Mr6He5Um7gHJ4W9JLWGROl2IHommcPkLzy/o2og29A4mTzOBioH6TAsGeNk QPyIuhjHKASD6PsU++e9HE04h3XW1vzY031bAfy6hjKtIBJOPy0lxBBjrKs+xnmT PWhE/GxXiVn00MxZstjBRcJqKLq4JQADX9MB7rp55Jr3GtVUo+mDMe8uJg4N+oSo rTv1vYfGRKGAC/xZQF6+5G15JdfowCh+sAWpjhzSU+h6Ci3TvyU+5zyCgXcLe7Mh NGYE4Jx1SY6BBXhn0Y4SqF7U5ENlI5F0eXEiF8092/xZA1gVwjW5qDFwKj4JlR88 kqYs3YGrcdtVKg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddriedtgddukecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhn ucevrdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkph epuddukedrvdduuddrudelledruddvieenucfrrghrrghmpehmrghilhhfrhhomhepthho sghinheskhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgepge X-ME-Proxy: Received: from eros.localdomain (ppp118-211-199-126.bras1.syd2.internode.on.net [118.211.199.126]) by mail.messagingengine.com (Postfix) with ESMTPA id BCD9FE427B; Sun, 17 Mar 2019 20:03:41 -0400 (EDT) From: "Tobin C. Harding" To: Andrew Morton Cc: "Tobin C. Harding" , Roman Gushchin , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 5/7] slub: Use slab_list instead of lru Date: Mon, 18 Mar 2019 11:02:32 +1100 Message-Id: <20190318000234.22049-6-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318000234.22049-1-tobin@kernel.org> References: <20190318000234.22049-1-tobin@kernel.org> MIME-Version: 1.0 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 Currently we use the page->lru list for maintaining lists of slabs. We have a list in the page structure (slab_list) that can be used for this purpose. Doing so makes the code cleaner since we are not overloading the lru list. Use the slab_list instead of the lru list for maintaining lists of slabs. Acked-by: Christoph Lameter Signed-off-by: Tobin C. Harding --- mm/slub.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index b282e22885cd..d692b5e0163d 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1023,7 +1023,7 @@ static void add_full(struct kmem_cache *s, return; lockdep_assert_held(&n->list_lock); - list_add(&page->lru, &n->full); + list_add(&page->slab_list, &n->full); } static void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct page *page) @@ -1032,7 +1032,7 @@ static void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct return; lockdep_assert_held(&n->list_lock); - list_del(&page->lru); + list_del(&page->slab_list); } /* Tracking of the number of slabs for debugging purposes */ @@ -1773,9 +1773,9 @@ __add_partial(struct kmem_cache_node *n, struct page *page, int tail) { n->nr_partial++; if (tail == DEACTIVATE_TO_TAIL) - list_add_tail(&page->lru, &n->partial); + list_add_tail(&page->slab_list, &n->partial); else - list_add(&page->lru, &n->partial); + list_add(&page->slab_list, &n->partial); } static inline void add_partial(struct kmem_cache_node *n, @@ -1789,7 +1789,7 @@ static inline void remove_partial(struct kmem_cache_node *n, struct page *page) { lockdep_assert_held(&n->list_lock); - list_del(&page->lru); + list_del(&page->slab_list); n->nr_partial--; } @@ -1863,7 +1863,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n, return NULL; spin_lock(&n->list_lock); - list_for_each_entry_safe(page, page2, &n->partial, lru) { + list_for_each_entry_safe(page, page2, &n->partial, slab_list) { void *t; if (!pfmemalloc_match(page, flags)) @@ -2407,7 +2407,7 @@ static unsigned long count_partial(struct kmem_cache_node *n, struct page *page; spin_lock_irqsave(&n->list_lock, flags); - list_for_each_entry(page, &n->partial, lru) + list_for_each_entry(page, &n->partial, slab_list) x += get_count(page); spin_unlock_irqrestore(&n->list_lock, flags); return x; @@ -3702,10 +3702,10 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) BUG_ON(irqs_disabled()); spin_lock_irq(&n->list_lock); - list_for_each_entry_safe(page, h, &n->partial, lru) { + list_for_each_entry_safe(page, h, &n->partial, slab_list) { if (!page->inuse) { remove_partial(n, page); - list_add(&page->lru, &discard); + list_add(&page->slab_list, &discard); } else { list_slab_objects(s, page, "Objects remaining in %s on __kmem_cache_shutdown()"); @@ -3713,7 +3713,7 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) } spin_unlock_irq(&n->list_lock); - list_for_each_entry_safe(page, h, &discard, lru) + list_for_each_entry_safe(page, h, &discard, slab_list) discard_slab(s, page); } @@ -3993,7 +3993,7 @@ int __kmem_cache_shrink(struct kmem_cache *s) * Note that concurrent frees may occur while we hold the * list_lock. page->inuse here is the upper limit. */ - list_for_each_entry_safe(page, t, &n->partial, lru) { + list_for_each_entry_safe(page, t, &n->partial, slab_list) { int free = page->objects - page->inuse; /* Do not reread page->inuse */ @@ -4003,10 +4003,10 @@ int __kmem_cache_shrink(struct kmem_cache *s) BUG_ON(free <= 0); if (free == page->objects) { - list_move(&page->lru, &discard); + list_move(&page->slab_list, &discard); n->nr_partial--; } else if (free <= SHRINK_PROMOTE_MAX) - list_move(&page->lru, promote + free - 1); + list_move(&page->slab_list, promote + free - 1); } /* @@ -4019,7 +4019,7 @@ int __kmem_cache_shrink(struct kmem_cache *s) spin_unlock_irqrestore(&n->list_lock, flags); /* Release empty slabs */ - list_for_each_entry_safe(page, t, &discard, lru) + list_for_each_entry_safe(page, t, &discard, slab_list) discard_slab(s, page); if (slabs_node(s, node)) @@ -4211,11 +4211,11 @@ static struct kmem_cache * __init bootstrap(struct kmem_cache *static_cache) for_each_kmem_cache_node(s, node, n) { struct page *p; - list_for_each_entry(p, &n->partial, lru) + list_for_each_entry(p, &n->partial, slab_list) p->slab_cache = s; #ifdef CONFIG_SLUB_DEBUG - list_for_each_entry(p, &n->full, lru) + list_for_each_entry(p, &n->full, slab_list) p->slab_cache = s; #endif } @@ -4432,7 +4432,7 @@ static int validate_slab_node(struct kmem_cache *s, spin_lock_irqsave(&n->list_lock, flags); - list_for_each_entry(page, &n->partial, lru) { + list_for_each_entry(page, &n->partial, slab_list) { validate_slab_slab(s, page, map); count++; } @@ -4443,7 +4443,7 @@ static int validate_slab_node(struct kmem_cache *s, if (!(s->flags & SLAB_STORE_USER)) goto out; - list_for_each_entry(page, &n->full, lru) { + list_for_each_entry(page, &n->full, slab_list) { validate_slab_slab(s, page, map); count++; } @@ -4639,9 +4639,9 @@ static int list_locations(struct kmem_cache *s, char *buf, continue; spin_lock_irqsave(&n->list_lock, flags); - list_for_each_entry(page, &n->partial, lru) + list_for_each_entry(page, &n->partial, slab_list) process_slab(&t, s, page, alloc, map); - list_for_each_entry(page, &n->full, lru) + list_for_each_entry(page, &n->full, slab_list) process_slab(&t, s, page, alloc, map); spin_unlock_irqrestore(&n->list_lock, flags); } From patchwork Mon Mar 18 00:02:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 10856715 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 61D9315AC for ; Mon, 18 Mar 2019 00:03:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4980F2919A for ; Mon, 18 Mar 2019 00:03:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DAD62922B; Mon, 18 Mar 2019 00:03: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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 899A02919A for ; Mon, 18 Mar 2019 00:03:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FBFE6B000C; Sun, 17 Mar 2019 20:03:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 45C516B000D; Sun, 17 Mar 2019 20:03: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 325366B000E; Sun, 17 Mar 2019 20:03:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 0FF876B000C for ; Sun, 17 Mar 2019 20:03:51 -0400 (EDT) Received: by mail-qk1-f200.google.com with SMTP id k29so13414218qkl.14 for ; Sun, 17 Mar 2019 17:03:51 -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:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=CxGqyPgRRgFsJNIUYcTQsfjDYACO56dLDTf5SGEtnkY=; b=pY1WEaDa7/4RDpBOPHSd4KX5Q07Qi9t6zX6JOLZD9fAjJ3Ujhf3/ot/y1MAMoJbM/6 xhEoHP7nlvYn0xL7EAE/xJvdAl1OsKVnTQ4X4nsonuH8jFd5OIWR0h+T3gwDcKZ8k5Wl aWaBy3dgL8jO38P432JQzsliBfH0cOX32/NSoZvXlcecDLZPl6E2Y3LZIcjT6QJziOic ejsrl2BrPIaU6EDNwKSA2uzoRleUr9ktfkC2rYSV2YBZz+y3GCkUEyaIgJR783eSFdjE pMf+vtL/Y3iM62X6zX/6/aWDfh/WevWgFYpR4Oc5SC1jN+5aSDujL4kHME01sb2rwOja k87w== X-Gm-Message-State: APjAAAX1aOjxI7BbvDk7aRqHQvZtVXwtSlrVVvTI7DEblsau/Rneky0n sCmgc4lAZlN5ckbX/7FXmokTZR33uNsxifLwPwDuoScSf0aLP2jIe7gAEYTYsmrG1l4MFBlv+8q lWO7N7pWHG4Xz96bs34dzG8aETetUl8QnrNH/eDUPNmPuPtDNS3+oMO7DM5P7Uvg= X-Received: by 2002:a37:4e0f:: with SMTP id c15mr11228037qkb.267.1552867430755; Sun, 17 Mar 2019 17:03:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxB0EZF+wPykJ38UjdD9VFyY93ZC7+HbTb2X+/v8g1twHqeZaxijOgYE7n3kot93Go3+hI4 X-Received: by 2002:a37:4e0f:: with SMTP id c15mr11227966qkb.267.1552867429363; Sun, 17 Mar 2019 17:03:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552867429; cv=none; d=google.com; s=arc-20160816; b=htKYpbjjlIvaCtPdzDRb/iUA6D+Ut+8jIEnu64QZL4kiX8TmRRjYFbXn1TZSDi5CdP ibLu2noRnH7CtCr5KW4WU9O2D60gE0SP8fGyZb8/XzFphMQ/9Oxs98LLqo+cWY7RjfNx 7lv4nTetVYmuGlAvUTpkxFX7V/5uEBStFbZzna3oillAm+7YiBbsp7xSVDcfqwxHl38q k+DC3J6K+39Z0PxTOUmnUIxQZRn+Vu/fu55nzUjNcqFK+VkD5ah5xhUoOBw6bw3vU70m ITEB/Bd2mF20AOkQ4VcVyJibL+X0M4UaiI6Ze8OscZliPdrswNG8e98uPPzDOOoQvf85 FLow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=CxGqyPgRRgFsJNIUYcTQsfjDYACO56dLDTf5SGEtnkY=; b=pw2hP7lbt6dD+nh3JKO7RsrT0jvPYhWwcNjH7s97L3PloIkWQYklJDMz2yJjz+cC0L 4S6uADM3Ud+FnhcGkmHEvgCXqA6xOLC/4kn4UsoyoT9TMVYAAMrC8LZgk7FK8T1NGUv5 raPJnq4w1tvOxPO59Yt7bbPQGw6z2Np+CT/WG5zk82uueK36clyOKbXbohoUq/lbkc5s utC/tq57htErffD/MyYQdPJrQH0wCRoMabhNtB7Mrx3bODUVI9yMOd4e+4JKnNcgpkWt 5cJ6YlBsfZo4akDOcZLggn4yp4RRK1/pA/0kj5lcGGjYAV/kWenBAKIaiC5lw3C9i/3B S3ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=n1HYWHWm; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com. [66.111.4.26]) by mx.google.com with ESMTPS id 23si3171707qtr.57.2019.03.17.17.03.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 17:03:49 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) client-ip=66.111.4.26; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=n1HYWHWm; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 1970221820; Sun, 17 Mar 2019 20:03:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 17 Mar 2019 20:03:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=CxGqyPgRRgFsJNIUYcTQsfjDYACO56dLDTf5SGEtnkY=; b=n1HYWHWm 5onIezhZH34mWPnV5UyDBgxW37ch7bs69caujnMC5qlcc7VnRg5irK8MPTdWO/yZ lWjQmK8AsLlfzgymz/u6+VP6GQgxEVA2Tva9ec0j9iHhBM9Gm19hJFLpFExgfHe4 264wlGye6YPRpjAaxsYwiWdHvazsWMLKGO7rzqng2qdgHKTieZBgf7pI+Px0bhhW 4p+J0RiLQUi8oJBXM+UaM+JtOr1A3oYigsmxRIcbmX+CacDW8qLkq0K9/eO4eWSc 56mq+fi10boqD3R8/fbtneUeb8Atxu5wBTakcmpnhrmui/p7Fl3haIHNtQQJFE9e QNqSzF4GO8cRTw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddriedtgddukecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhn ucevrdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkph epuddukedrvdduuddrudelledruddvieenucfrrghrrghmpehmrghilhhfrhhomhepthho sghinheskhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgepge X-ME-Proxy: Received: from eros.localdomain (ppp118-211-199-126.bras1.syd2.internode.on.net [118.211.199.126]) by mail.messagingengine.com (Postfix) with ESMTPA id 96DBBE4753; Sun, 17 Mar 2019 20:03:45 -0400 (EDT) From: "Tobin C. Harding" To: Andrew Morton Cc: "Tobin C. Harding" , Roman Gushchin , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 6/7] slab: Use slab_list instead of lru Date: Mon, 18 Mar 2019 11:02:33 +1100 Message-Id: <20190318000234.22049-7-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318000234.22049-1-tobin@kernel.org> References: <20190318000234.22049-1-tobin@kernel.org> MIME-Version: 1.0 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 Currently we use the page->lru list for maintaining lists of slabs. We have a list in the page structure (slab_list) that can be used for this purpose. Doing so makes the code cleaner since we are not overloading the lru list. Use the slab_list instead of the lru list for maintaining lists of slabs. Signed-off-by: Tobin C. Harding --- mm/slab.c | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index 28652e4218e0..09cc64ef9613 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1710,8 +1710,8 @@ static void slabs_destroy(struct kmem_cache *cachep, struct list_head *list) { struct page *page, *n; - list_for_each_entry_safe(page, n, list, lru) { - list_del(&page->lru); + list_for_each_entry_safe(page, n, list, slab_list) { + list_del(&page->slab_list); slab_destroy(cachep, page); } } @@ -2265,8 +2265,8 @@ static int drain_freelist(struct kmem_cache *cache, goto out; } - page = list_entry(p, struct page, lru); - list_del(&page->lru); + page = list_entry(p, struct page, slab_list); + list_del(&page->slab_list); n->free_slabs--; n->total_slabs--; /* @@ -2726,13 +2726,13 @@ static void cache_grow_end(struct kmem_cache *cachep, struct page *page) if (!page) return; - INIT_LIST_HEAD(&page->lru); + INIT_LIST_HEAD(&page->slab_list); n = get_node(cachep, page_to_nid(page)); spin_lock(&n->list_lock); n->total_slabs++; if (!page->active) { - list_add_tail(&page->lru, &(n->slabs_free)); + list_add_tail(&page->slab_list, &n->slabs_free); n->free_slabs++; } else fixup_slab_list(cachep, n, page, &list); @@ -2841,9 +2841,9 @@ static inline void fixup_slab_list(struct kmem_cache *cachep, void **list) { /* move slabp to correct slabp list: */ - list_del(&page->lru); + list_del(&page->slab_list); if (page->active == cachep->num) { - list_add(&page->lru, &n->slabs_full); + list_add(&page->slab_list, &n->slabs_full); if (OBJFREELIST_SLAB(cachep)) { #if DEBUG /* Poisoning will be done without holding the lock */ @@ -2857,7 +2857,7 @@ static inline void fixup_slab_list(struct kmem_cache *cachep, page->freelist = NULL; } } else - list_add(&page->lru, &n->slabs_partial); + list_add(&page->slab_list, &n->slabs_partial); } /* Try to find non-pfmemalloc slab if needed */ @@ -2880,20 +2880,20 @@ static noinline struct page *get_valid_first_slab(struct kmem_cache_node *n, } /* Move pfmemalloc slab to the end of list to speed up next search */ - list_del(&page->lru); + list_del(&page->slab_list); if (!page->active) { - list_add_tail(&page->lru, &n->slabs_free); + list_add_tail(&page->slab_list, &n->slabs_free); n->free_slabs++; } else - list_add_tail(&page->lru, &n->slabs_partial); + list_add_tail(&page->slab_list, &n->slabs_partial); - list_for_each_entry(page, &n->slabs_partial, lru) { + list_for_each_entry(page, &n->slabs_partial, slab_list) { if (!PageSlabPfmemalloc(page)) return page; } n->free_touched = 1; - list_for_each_entry(page, &n->slabs_free, lru) { + list_for_each_entry(page, &n->slabs_free, slab_list) { if (!PageSlabPfmemalloc(page)) { n->free_slabs--; return page; @@ -2908,11 +2908,12 @@ static struct page *get_first_slab(struct kmem_cache_node *n, bool pfmemalloc) struct page *page; assert_spin_locked(&n->list_lock); - page = list_first_entry_or_null(&n->slabs_partial, struct page, lru); + page = list_first_entry_or_null(&n->slabs_partial, struct page, + slab_list); if (!page) { n->free_touched = 1; page = list_first_entry_or_null(&n->slabs_free, struct page, - lru); + slab_list); if (page) n->free_slabs--; } @@ -3413,29 +3414,29 @@ static void free_block(struct kmem_cache *cachep, void **objpp, objp = objpp[i]; page = virt_to_head_page(objp); - list_del(&page->lru); + list_del(&page->slab_list); check_spinlock_acquired_node(cachep, node); slab_put_obj(cachep, page, objp); STATS_DEC_ACTIVE(cachep); /* fixup slab chains */ if (page->active == 0) { - list_add(&page->lru, &n->slabs_free); + list_add(&page->slab_list, &n->slabs_free); n->free_slabs++; } else { /* Unconditionally move a slab to the end of the * partial list on free - maximum time for the * other objects to be freed, too. */ - list_add_tail(&page->lru, &n->slabs_partial); + list_add_tail(&page->slab_list, &n->slabs_partial); } } while (n->free_objects > n->free_limit && !list_empty(&n->slabs_free)) { n->free_objects -= cachep->num; - page = list_last_entry(&n->slabs_free, struct page, lru); - list_move(&page->lru, list); + page = list_last_entry(&n->slabs_free, struct page, slab_list); + list_move(&page->slab_list, list); n->free_slabs--; n->total_slabs--; } @@ -3473,7 +3474,7 @@ static void cache_flusharray(struct kmem_cache *cachep, struct array_cache *ac) int i = 0; struct page *page; - list_for_each_entry(page, &n->slabs_free, lru) { + list_for_each_entry(page, &n->slabs_free, slab_list) { BUG_ON(page->active); i++; @@ -4336,9 +4337,9 @@ static int leaks_show(struct seq_file *m, void *p) check_irq_on(); spin_lock_irq(&n->list_lock); - list_for_each_entry(page, &n->slabs_full, lru) + list_for_each_entry(page, &n->slabs_full, slab_list) handle_slab(x, cachep, page); - list_for_each_entry(page, &n->slabs_partial, lru) + list_for_each_entry(page, &n->slabs_partial, slab_list) handle_slab(x, cachep, page); spin_unlock_irq(&n->list_lock); } From patchwork Mon Mar 18 00:02:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 10856717 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 4E19315AC for ; Mon, 18 Mar 2019 00:03:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36F822919A for ; Mon, 18 Mar 2019 00:03:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B30A2922B; Mon, 18 Mar 2019 00:03:56 +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,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 B90802919A for ; Mon, 18 Mar 2019 00:03:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 945DB6B000D; Sun, 17 Mar 2019 20:03:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8A21D6B000E; Sun, 17 Mar 2019 20:03:54 -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 791A86B0010; Sun, 17 Mar 2019 20:03:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 4D6166B000D for ; Sun, 17 Mar 2019 20:03:54 -0400 (EDT) Received: by mail-qk1-f198.google.com with SMTP id w134so13311371qka.6 for ; Sun, 17 Mar 2019 17:03:54 -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:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BFIyNbFQfvFKfyZUHijpqSaVm8ggK3M3/XYK2FaoXEA=; b=Y4sWNjiQ6/YPhGdRbiq2WYTantuYYpvbQ7iUOggZ2AG/0jRLX61TXkXwfPzgpRPPoG lMlM/31+p5B6GgLTf5NNpssId115TEnV65JO3I9qJZR5D99IrZ3fuUr8rL27Ytj/cILj VEn5MpVptZ9lP5A5Lpy5YhMdiFcWEtQj/l41q8/W4/CTGYNM2KFseShJFQ9n5UtitYWb y0U796fcbo6VCI+35alJy3zWyBCzrGbivb4h2dESkYk4QrIiOQOiBGXNRFLyjfD97viA cwfA8yAHZQp7BsFtrAm88vBs667OVe/kySVmM4Z7vv+J/9Jw2bDJbn7gxugCzirRPU0L 3Rzw== X-Gm-Message-State: APjAAAWcRmTHhOA3B7OkHrHSkz5sSgBNNqrDTVjHjEPCW8T+tw0FEcn9 gee2IDEtSmktDe3ZqSraMdoerjrR7k59Z8KTXyiZlldzmACIqKHoX9LZaSw76cRiTfZifmyQbvE EtqjM9Tqy7o/VRghySSrVOrXM3AZOxeIOxfSlspIVerynOfCuKV29LltThssl+uk= X-Received: by 2002:a37:a14:: with SMTP id 20mr489050qkk.265.1552867434095; Sun, 17 Mar 2019 17:03:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDhXFjA6dIqDzcAxP3ErwuZ7Zdueyg8uLkGPD1gXyHHbWiDztSnChqkmGDPJ/wpbHepXfI X-Received: by 2002:a37:a14:: with SMTP id 20mr489008qkk.265.1552867433155; Sun, 17 Mar 2019 17:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552867433; cv=none; d=google.com; s=arc-20160816; b=iEnOytBJ4bcffd5c4Tmwxm9+VcA3cqSb89nkyrJcjAH2kahQCJd69gyz+iiD0joBkn JohAEiXt44PLoCqgX00yK5UWqftqaNa2f0tvofhcqnSAxTvJ9WMZFrdzH3kdCdfVfAuQ FDjvWV6jDkyPBcXk0+Wtf1/AY/kgvd+JSr28KiZknjDlBHVndYnLVQuYnXEJ7ADAQ5fk Czew0y5wtkCObhkVx4oL37wdcJxZL45kwN9RL0XCe4WfvtsWUi/v9qHV7M6NU+cLIoF/ njVt/S/R6uy83kJji2Ux4pTo5fgQ7HwqvNQjr+ShsD52EE+7VTcU7OHBmQE/1pCNUUpD a+wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=BFIyNbFQfvFKfyZUHijpqSaVm8ggK3M3/XYK2FaoXEA=; b=N8rUH3/P5NB7vrXRFnTs87fNlPr/Xa5MHZBJGxEbObbOW1q5itj3hRbgnr+tnDhNSs fenwdIFXtQGYFTStvUm7bIz+Ly361WIcp+KepzbORkoFpuQu83kU4jN9ObiKzD7B6gLd PW3mN1mKOgEw31oYm2cmeqNgHex7AKoiJv48NatPzBTe7FGdDw5C03d7mQWwSZB9m3se lLlX+0vj8+ju/X9yfQ4m1pfiqStrymlwSn1E1k32gjIExCI8QVRgEU8OUv1uXesDrbsD CcaRX6MVbaI6Im8hpoG9JgxypZGuBF5Bz/lTHuwqmHa5QXXTNva3SaMjX+t+KJ/5fa8a 5iAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=KOAmRspW; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com. [66.111.4.26]) by mx.google.com with ESMTPS id q70si3941399qka.246.2019.03.17.17.03.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 17:03:53 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) client-ip=66.111.4.26; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=KOAmRspW; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.26 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id D72E2210A8; Sun, 17 Mar 2019 20:03:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 17 Mar 2019 20:03:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=BFIyNbFQfvFKfyZUHijpqSaVm8ggK3M3/XYK2FaoXEA=; b=KOAmRspW zBQVWYQ7vICgKRiQqNhAMtncIDQke6ig3Hz+sdddxUlCSTlcQT1rCLx5IszqwTh7 JebvNswcv0GRgndUA3DVZVYb84T+t/L2RHTx+BGPq+Hydz1wdannzgYxtSLOSQJ0 hwp/WX4SJWXnGVtZnVFeVJxsoEHjYOH8WnLLcm4vqnRCSzg2BFzJiU5D5WaPjqwv QNezb8UZvFW2/fvKBcqWtiuUOkm1Zu0XqKTAVALxQYKfBYmpseslQb6wMpaeSAAs Y59viX8Gu+BcUOaar/P+dMz5U3L1T5bzMsEvdWPDKkpj9HEeFzMMqoLmp5Oi12Qk q4QxuDgpnAzhqQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddriedtgddukecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhn ucevrdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkph epuddukedrvdduuddrudelledruddvieenucfrrghrrghmpehmrghilhhfrhhomhepthho sghinheskhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgepie X-ME-Proxy: Received: from eros.localdomain (ppp118-211-199-126.bras1.syd2.internode.on.net [118.211.199.126]) by mail.messagingengine.com (Postfix) with ESMTPA id 70051E4684; Sun, 17 Mar 2019 20:03:49 -0400 (EDT) From: "Tobin C. Harding" To: Andrew Morton Cc: "Tobin C. Harding" , Roman Gushchin , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 7/7] mm: Remove stale comment from page struct Date: Mon, 18 Mar 2019 11:02:34 +1100 Message-Id: <20190318000234.22049-8-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318000234.22049-1-tobin@kernel.org> References: <20190318000234.22049-1-tobin@kernel.org> MIME-Version: 1.0 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 We now use the slab_list list_head instead of the lru list_head. This comment has become stale. Remove stale comment from page struct slab_list list_head. Acked-by: Christoph Lameter Signed-off-by: Tobin C. Harding --- include/linux/mm_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 7eade9132f02..63a34e3d7c29 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -103,7 +103,7 @@ struct page { }; struct { /* slab, slob and slub */ union { - struct list_head slab_list; /* uses lru */ + struct list_head slab_list; struct { /* Partial pages */ struct page *next; #ifdef CONFIG_64BIT