From patchwork Fri Nov 15 19:02:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 13876708 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7503BD68BCD for ; Fri, 15 Nov 2024 19:02:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1BB136B00A1; Fri, 15 Nov 2024 14:02:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 169D26B00A3; Fri, 15 Nov 2024 14:02:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 056B56B00A5; Fri, 15 Nov 2024 14:02:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DF3476B00A1 for ; Fri, 15 Nov 2024 14:02:50 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 90CAB41C0B for ; Fri, 15 Nov 2024 19:02:50 +0000 (UTC) X-FDA: 82789248108.17.208F7CF Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) by imf06.hostedemail.com (Postfix) with ESMTP id 747C418001A for ; Fri, 15 Nov 2024 19:02:16 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=PS2jU747; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.180 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731697304; a=rsa-sha256; cv=none; b=xhX0SDApv8vGwvl6y8r3Jn6H2DgRIe/bmUdEA9ye5jWuu0asez9sN1fLHlexKs1Karw2s6 4M9q/cmvXuEQmQTTSxG2mN9P7+gGlSw44U7/vCQUU5XFVgqeHOyTHGL/7oLG2pbP47EBMA kJdb4tKEL6nLSgWUwZk22j9A/tkD9W8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=PS2jU747; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.180 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731697304; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cChRt8Y/7rNJ+UE7EiKYAmqcqG+mD3DTpu3d12HPnTc=; b=3vm2JlhDi5J7xa4soq/9Q5tt+TGb7Ak8fKkgab5gyPmVyTYXDJ0e2PjjQt9oiZ5/oOF52N JO7JFPpuM4S8VlOqVRSJzjVJKYpArObitb9U/iZrdp9uq0r3In/eX5es/lFT4/oKAv+shW wmBCLg0jtFl9UU73kJTPTsue8AI2fGY= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1731697367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cChRt8Y/7rNJ+UE7EiKYAmqcqG+mD3DTpu3d12HPnTc=; b=PS2jU747h5/TqBqugYikH8pMT78fDosPtIf0M28FYdx2T7/Gr6zIEe3lht9AD5mbdmazLO S/zp1C2BigugXatQzPfouGIr828SdBJx3dPkpETc6WcAlS9TlVhmpjTy4kiwR9wm69Woz+ rtBwb/L6PPRRVYlYQGVLrRotXjfdrbw= From: Roman Gushchin To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt , Michal Hocko , Johannes Weiner , Roman Gushchin Subject: [PATCH 2/2] mm: swap_cgroup: get rid of __lookup_swap_cgroup() Date: Fri, 15 Nov 2024 19:02:29 +0000 Message-ID: <20241115190229.676440-2-roman.gushchin@linux.dev> In-Reply-To: <20241115190229.676440-1-roman.gushchin@linux.dev> References: <20241115190229.676440-1-roman.gushchin@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Queue-Id: 747C418001A X-Rspamd-Server: rspam11 X-Stat-Signature: dwg79ykhnzrx3oa63c317wbdfdympkrr X-HE-Tag: 1731697336-960174 X-HE-Meta: U2FsdGVkX1+UVhQgqrHSY4PIy5Itn2E4RszFHY08RaIspWgC4pYF0I/72c44y1un4FxCsmVpT6GkIJupjo7ONr4wKIl6/6cr4GbEM92e23aE+p1PiAq3330YSx/Rn8R5mGF/7ZwO0QUX9Hl+tf0+YrxUkgvBYAxImvkFmtN7x3VjJYrpzmoK400skwUOrOZktXttLzI1Ohc78W7fudpYgN9uf2TlK8le9ywJn9/M4fkCTGSPXLDKLFcI4GjuNHNygfSCA9S88nKSzq1k8ETSPFX/UKDnRQkSVlrv6BR0djSkmvr3CaewZ37Ae/ug9J7U4k91LBx+vSZc1mdADCrqpaBSsODu3OuXDCzD693xSU7J4TYDa5xopfCLVrlcb7e85RHgHux5Hu9xSHDPRSLRXqbd+7ziZW+kGcArodkAOAeUy2MPHP4gPL4qcQik4BDkfyH6ShKgT3wMDpRIlfYRDo4KOi64EW/oM0ULIN7CGzFJ52+vgtLOGCixDEHg85S+j/4i09YCrwLf628sVKPmanQpMPpVn9OQgnb8OM5YOmkgUFV7BARRi4RRe7LRU7mwcyaFQwDqkc3JN/Ze42i9dqeRyVREvAJSTendEAH7/2pzV1rtqmHRTpKsQxKKuAv8LnR/ZzzoBOI+R8r2diwG6BwSeGaxhJDlvImp1lharzr9HCOo9RCT/0awslWg9zawumSbYy8TKnee12cXC9QCxyXu7UIOLbBvdChppNhEDxe0jlZdT+cVird1TAgFSQcwTjmW4/pxh+bY8wkkn4pShJeSInRw5ZctIn5JDoTreA4WtRoDJKk4ioyLRPEZZsPaDQTW45Yfb8OYbwdw/liyFhX8rz+WBZDgJbjBOISyQjFjTlXFXBJ3EcYfHy9NGjs6PVBOm3X8XNeRgV/+YkhTlLZtqS3+p7modsjJTHsSwTPaaS4ymMmsSwkW9JP58owm69BgI9zjW0cwWCBcWsY VrMfJzaL Lm/uxDKpBNKwFeJOcwU/UlobfxQcejAUDnzWSA08Rd78l+Jdhjp/8VLGTDYCI1nhzzkLgugKHxyQU9NEgNrnQdSYnIwPjvSbolNzpP9vnJM6RS4pLRkrE3NKoUNR0t6Iy1GqgnRjgwdZMOfSuJL86rHTJkvghA1E4egbtXKYF9goAiFEiBZhkVvbkDA== 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: List-Subscribe: List-Unsubscribe: Because swap_cgroup map is now virtually contiguous, swap_cgroup_record() can be simplified, which eliminates a need to use __lookup_swap_cgroup(). Now as __lookup_swap_cgroup() is really trivial and is used only once, it can be inlined. Signed-off-by: Roman Gushchin Acked-by: Shakeel Butt --- mm/swap_cgroup.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/mm/swap_cgroup.c b/mm/swap_cgroup.c index 18de498c84a4..0db907308c94 100644 --- a/mm/swap_cgroup.c +++ b/mm/swap_cgroup.c @@ -33,13 +33,6 @@ static struct swap_cgroup_ctrl swap_cgroup_ctrl[MAX_SWAPFILES]; * * TODO: we can push these buffers out to HIGHMEM. */ - -static struct swap_cgroup *__lookup_swap_cgroup(struct swap_cgroup_ctrl *ctrl, - pgoff_t offset) -{ - return &ctrl->map[offset]; -} - static struct swap_cgroup *lookup_swap_cgroup(swp_entry_t ent, struct swap_cgroup_ctrl **ctrlp) { @@ -49,7 +42,7 @@ static struct swap_cgroup *lookup_swap_cgroup(swp_entry_t ent, ctrl = &swap_cgroup_ctrl[swp_type(ent)]; if (ctrlp) *ctrlp = ctrl; - return __lookup_swap_cgroup(ctrl, offset); + return &ctrl->map[offset]; } /** @@ -104,16 +97,9 @@ unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id, spin_lock_irqsave(&ctrl->lock, flags); old = sc->id; - for (;;) { + for (; offset < end; offset++, sc++) { VM_BUG_ON(sc->id != old); sc->id = id; - offset++; - if (offset == end) - break; - if (offset % SC_PER_PAGE) - sc++; - else - sc = __lookup_swap_cgroup(ctrl, offset); } spin_unlock_irqrestore(&ctrl->lock, flags);