Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3899540imm; Mon, 17 Sep 2018 05:10:30 -0700 (PDT) X-Google-Smtp-Source: ANB0VdakZoyXP8Tmzxv6rHPfwF5bq2YrnRVFLXcE/XfNqBBizu1tb46yMd9jt42g7W5YW+0Qw9DY X-Received: by 2002:a17:902:7b96:: with SMTP id w22-v6mr24200857pll.24.1537186230762; Mon, 17 Sep 2018 05:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537186230; cv=none; d=google.com; s=arc-20160816; b=VYCE31JHtfIKm8krJGaopzB/igh7+pBUJaeHEJIT/Udbs3c9VqDonOzGrI3K8XzHsH MxSGPIux4fG6iI/3Zo+Lb03L4Sa7U7LLwcUjFgCpj3OMLt+69JQ3MP5gOxA4LFb5oCxb LhvCf1ua8HWqULEJac/Cc9gD9YE70WB/NV6xeuP+cclAsjpHM1+MeFLu/AplzNwFmX84 MiYx22qsJJEMwnhKuqOaXtW66e/wbnlLilCwWlLPTmkQvwSXlkkrZRgRCYHanS8rvEEi jzsPy9qL9+30vO/fJR9T60EmJhf93+P5iK/UkTgcyMN93iJ0WDZ4wwkOS1eP/Z5kf7ne MFOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=01xnjUBjpsg6KuuGXx13wnd3HzOPmCqvqdiDn4zfD8Y=; b=qROzZy3j1Fl/6bHE5abezNNELbNpewbUrx00LgneNoaa5KekeJdLBjtxFFztkcav9p rCQTHzfHg/1ohjq0MZ1Zqf+IuRbemh4RolX/ZDMuVUwe9WJBSsSUqMqQqGDH0l4O02NQ bEqAmNhHyDUNteGqkfrrQG+mFcUnLBOSMPo9tzgiZ0B1jPsdSahF08O1SyZknGayGj/7 zRAfNYDO8JZr6TsdabXwPobIcNPVmgIJaP4PbYgaHFfSsQKAZnWjev4CAvXVQmw/x+WF PH0Ak0FBafy0SWU6gu7Ea6cQKmZXi5snhUwX/eFr0vvC+6O/q5zcxQX52PJYyGLh3awa MmlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Dem8uHLo; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5-v6si14734863pgk.200.2018.09.17.05.10.13; Mon, 17 Sep 2018 05:10:30 -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=@gmail.com header.s=20161025 header.b=Dem8uHLo; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728461AbeIQRfl (ORCPT + 99 others); Mon, 17 Sep 2018 13:35:41 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38851 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728241AbeIQRfk (ORCPT ); Mon, 17 Sep 2018 13:35:40 -0400 Received: by mail-wm1-f68.google.com with SMTP id t25-v6so9266058wmi.3 for ; Mon, 17 Sep 2018 05:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=01xnjUBjpsg6KuuGXx13wnd3HzOPmCqvqdiDn4zfD8Y=; b=Dem8uHLo/PJWAxqKDdpm6EfnTRbyUtqqkQK1ZK2pezUqYmB5UdDO92iTvhEpcspCNR jzec9RaaX7sIDzBZSsfD7+ArrRS+kA2IqDHzCCD5RS1O8a6Nlc+ssFcPn9DFtCd7vOh2 peOl3VHNrfwkvMy6CxH12zHKoztgNLMNKZgVSGUs7x7my9+49/0DIgPCnrPynsRO8z1m W/jh8hY29xVgku2H+ZAg4ZrVC5YE43fh/qCRsXXM+QAEzCBzD5epjbK3EFS3ud3ShQTa 5lOjYsgsZtuxy3GWB0Zrye9wR3Dt2q/KkxZsw74H0QjHN+She1xPwHXRyN1YTRRbXnff zazw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=01xnjUBjpsg6KuuGXx13wnd3HzOPmCqvqdiDn4zfD8Y=; b=EycTaAcGB9MJu2IZx9hGv7HLRI9l7td5ifDdBqSY8hk1f2l3peP7F1bNkxhAO0x49Y a+3QbZqmKHDu2Cx+BQvVFEow2vYl7SoZ0U3uQGuJoWbXg4vBKMpwQcZ7jdoID18IKTxm AKbtR1D+xhEvHNH+K5j3gq8aYWjKM+GjvVf3mc8FvyA2SGJWe6mV+bI/+ajdF/UnAXzp YbMdoyJpcZQ8DY/9Eds1uJdxGYGzt/alAv/lQ+lSpnJAP118VW9E8TfFkAArWgk1zrZT AFX8kTYmSN/ScoHaoO+J7Vd8pQEReJHTCi/LrNtxqurEUoJAst7mRsigrbjweLZNP53Z eS/A== X-Gm-Message-State: APzg51D4wTI7J00aRKxhbRUdSF/T6GRjue4qcbfbP+w6TDvfwcfF9xZ1 6MTrBBjyqj21qWma9nUgL2olecvm X-Received: by 2002:a1c:3503:: with SMTP id c3-v6mr11122272wma.46.1537186116009; Mon, 17 Sep 2018 05:08:36 -0700 (PDT) Received: from baker.fritz.box ([2a02:908:1257:4460:21bc:9ef5:2350:67f5]) by smtp.gmail.com with ESMTPSA id v6-v6sm11608213wro.66.2018.09.17.05.08.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Sep 2018 05:08:35 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH] list: introduce list_bulk_move_tail helper Date: Mon, 17 Sep 2018 14:08:34 +0200 Message-Id: <20180917120834.13993-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move all entries between @first and including @last before @head. This is useful for LRU lists where a whole block of entries should be moved to the end of the list. Used as a band aid in TTM, but better placed in the common list headers. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 25 +++++-------------------- include/linux/list.h | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index b2a33bf1ef10..26b889f86670 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -247,20 +247,6 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo, } EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); -static void ttm_list_move_bulk_tail(struct list_head *list, - struct list_head *first, - struct list_head *last) -{ - first->prev->next = last->next; - last->next->prev = first->prev; - - list->prev->next = first; - first->prev = list->prev; - - last->next = list; - list->prev = last; -} - void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) { unsigned i; @@ -276,8 +262,8 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) reservation_object_assert_held(pos->last->resv); man = &pos->first->bdev->man[TTM_PL_TT]; - ttm_list_move_bulk_tail(&man->lru[i], &pos->first->lru, - &pos->last->lru); + list_bulk_move_tail(&man->lru[i], &pos->first->lru, + &pos->last->lru); } for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { @@ -291,8 +277,8 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) reservation_object_assert_held(pos->last->resv); man = &pos->first->bdev->man[TTM_PL_VRAM]; - ttm_list_move_bulk_tail(&man->lru[i], &pos->first->lru, - &pos->last->lru); + list_bulk_move_tail(&man->lru[i], &pos->first->lru, + &pos->last->lru); } for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { @@ -306,8 +292,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) reservation_object_assert_held(pos->last->resv); lru = &pos->first->bdev->glob->swap_lru[i]; - ttm_list_move_bulk_tail(lru, &pos->first->swap, - &pos->last->swap); + list_bulk_move_tail(lru, &pos->first->swap, &pos->last->swap); } } EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail); diff --git a/include/linux/list.h b/include/linux/list.h index de04cc5ed536..edb7628e46ed 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -183,6 +183,29 @@ static inline void list_move_tail(struct list_head *list, list_add_tail(list, head); } +/** + * list_bulk_move_tail - move a subsection of a list to its tail + * @head: the head that will follow our entry + * @first: first entry to move + * @last: last entry to move, can be the same as first + * + * Move all entries between @first and including @last before @head. + * All three entries must belong to the same linked list. + */ +static inline void list_bulk_move_tail(struct list_head *head, + struct list_head *first, + struct list_head *last) +{ + first->prev->next = last->next; + last->next->prev = first->prev; + + head->prev->next = first; + first->prev = head->prev; + + last->next = head; + head->prev = last; +} + /** * list_is_last - tests whether @list is the last entry in list @head * @list: the entry to test -- 2.14.1