From patchwork Thu Jan 30 11:51:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13954516 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 4CBB6C0218A for ; Thu, 30 Jan 2025 11:52:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA3C96B0172; Thu, 30 Jan 2025 06:52:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B53836B0173; Thu, 30 Jan 2025 06:52:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CD506B0174; Thu, 30 Jan 2025 06:52:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7B5976B0172 for ; Thu, 30 Jan 2025 06:52:56 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D6A37A0CE2 for ; Thu, 30 Jan 2025 11:52:55 +0000 (UTC) X-FDA: 83063956710.29.76B44C6 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf07.hostedemail.com (Postfix) with ESMTP id 1034640009 for ; Thu, 30 Jan 2025 11:52:53 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FF2hbjCo; spf=pass (imf07.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738237974; h=from:from:sender:reply-to: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:references:dkim-signature; bh=IRdhxOCLTpy7gXxz6UiEgdB2jzKV6kI5ur0vXFJRzAU=; b=a4IytQGcda91+BRxQszFz6TkcTW1Uuw0TDOQtol0RVnu13oYcCuuyRI7CYJPhd3m/8Q7Xz BJDIOIGMyID8j03EvcYayNbIGoptUX6gO3u1x5s1tZRwASldEX+JmD4eqkx7fCkmGtO5Ju KfomdbzRRIwCp8T3xELQSkQzpV2GZmQ= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FF2hbjCo; spf=pass (imf07.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738237974; a=rsa-sha256; cv=none; b=Vd3tS+ZMeete1T7cR87ySlF5xZrZvG6PAV5atn7TKb798KIE81+bP/n5gp3hZZdtEgXUDS tc5INVGQSHbMbDf8X+jsVVJk7HhOGMKOqzZQjJoUENPLNg2+kmIvNpahxe7pKavy6FzHEk E+Kk1q6XUom1LWGfd6PAQ4nwOnmU7vM= Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-2ef70c7efa5so830718a91.2 for ; Thu, 30 Jan 2025 03:52:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738237972; x=1738842772; darn=kvack.org; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=IRdhxOCLTpy7gXxz6UiEgdB2jzKV6kI5ur0vXFJRzAU=; b=FF2hbjCo3l2i8AJEOaA4LlcnKYuFA38GzaVxK/1PvV5C5pt9O3vyRkF5rAmzTsceIj Bl81bE67TzS6zKvUDYH5KXGw4KgB9F0VLigSqa/lep+hC5mz4lSqTRvM8N5s1MJpzgx6 qxXg+X7S7sZ99riDA8UxYyTjjqfKtvqWZYJc0R7L017yiYmVJsXGFr5I2QXOdV4OnrF2 VbdaGLv2iWOalzlx20ByrLpFU4wRGTzBTEplpuFkFWdpPYBXqS/CzYWnG1Lo8jXV1otH iH5csd5HTUYXKvWufQvHKbYpqdTsV0zBBbQ45c1AvcwwFRYsscokneloZ+q+plySKGBT fakw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738237972; x=1738842772; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IRdhxOCLTpy7gXxz6UiEgdB2jzKV6kI5ur0vXFJRzAU=; b=GIR/+HEQO9+IkzkTQQ+BytCzZuJ7OY+wsmFGAMhv2bTQirKzedCzOey34KpZX45wd/ 9/lGnhWUWUqDwrLi4HMTgQrHZM9yduIAG3pN1vpEHINAKoFOkT3Mj1nE53fX3i2uxt1M W6Ubzw5e42SJsgJxCcJITDLJdqJOSchV+MhV3qniPAVwi+zM9i7Eg7x7OUMSBiwVFK0M AY2fNI53CAKosnEXOK6l2BfIvxHdqLN+8Ck9FPWQOXVKa/nHN0qcKsj4Wl2B2Wh9hZSZ O7y6mNpUwmAlHawBOEHOIwad8EEhJbfT7vW1e1Q1DAm5YeEYaAQo/x2fRl3Im3ZBMRmq iOgA== X-Gm-Message-State: AOJu0YxrWUYHeUQP2XfxjyEgeDy54+Meq4keidBOeeEwuo4cLt+8e42T mx6of8x1fs4A5ZfNHZXR4RgvqBByQtSwArnYawLC0aVZ9R2c2+nSz307Uf20TAM= X-Gm-Gg: ASbGnctyE/woFZ1qThULDBWsEfavkpsMshHDcLIXqJHkp4GyFgEuCOTLV95FqjbRdeK /VJl+ced66HZUlu/LG4e3J+4zBfnHqp2r8488oAVjWwnEIMAofMkKUOc7O6unovGof8VJPOZO6Z rgPc+s7RRPJlk93uz5hzJapjMY5VFYzP1lrkXfjIrc9y+1if/pmBNWG4dLb74lh5z9QrIKfGggF 0ICqFyEUb7ArWOsXrduNR94dYw6j1xLuzE+esgIKwzGK2nJ5Iidb//yQ7kP0zzjDkoxl8CMXIcl Oghmfn7eH7iJRYtV/u8th14GH53kAfZUNTY= X-Google-Smtp-Source: AGHT+IH3bJvIJrlvODXBiQSblyjvCfrjpno+BrzIiXcQsfAkh+tEDUmwi0APm6B3BYOOad/++Q5m7w== X-Received: by 2002:a17:90a:c888:b0:2f4:434d:c7f0 with SMTP id 98e67ed59e1d1-2f83abe98cfmr11283770a91.12.1738237972244; Thu, 30 Jan 2025 03:52:52 -0800 (PST) Received: from localhost.localdomain ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f8489d3982sm1541031a91.24.2025.01.30.03.52.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 30 Jan 2025 03:52:51 -0800 (PST) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Chris Li , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH] mm, swap: fix reclaim offset calculation error during allocation Date: Thu, 30 Jan 2025 19:51:31 +0800 Message-ID: <20250130115131.37777-1-ryncsn@gmail.com> X-Mailer: git-send-email 2.48.1 Reply-To: Kairui Song MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 1034640009 X-Stat-Signature: e7m8qseigz6m7js7hkbc4jmy37xehc88 X-Rspam-User: X-HE-Tag: 1738237973-76814 X-HE-Meta: U2FsdGVkX19y54I3ZJgrywpMqisGc9Q4oMe6lv4tetxxbL2I7j8MJD5nDYO8uKgDWQwwUXmBvERIhL+yvUkZig+Slf1+ImSmmn3/EiTFm7tDXW1HCM3IBCBJe8oraCx+VO0kOOY0BJEQjF6n/P4OL6uvGWRyqJUBaUA9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23IJy532cUVHgUvYZrZAqC8IUdPGlOwNavzQ7/ujyJ7dZLmpsl/YpEDZyAfwPjiTNnd2iyv/+V1tnEheH/96/rIK60OeMeNf+s5nwIK/x+/8wSfnpGXGYgswixRvLw8Am7XPV2S8g3Kmqh5fiAlj+KgPmi2EiTta5XxLm9POdQGXJ7+Y9zu4C4pyoRTJwuguERfSxp3DqxcqS1ibcXDmtmglpEyEiic9l7nD7TfMrmHrrrHTrkgPm6HKadj1C24JEuw0AyfyKfBgXBKs3djuGFiL6yfnilVagwSGg== 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: From: Kairui Song There is a code error that will cause the swap entry allocator to reclaim and check the whole cluster with an unexpected tail offset instead of the part that needs to be reclaimed. This may cause corruption of the swap map, so fix it. Fixes: 3b644773eefd ("mm, swap: reduce contention on device lock") Signed-off-by: Kairui Song --- mm/swapfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 6e867c16ea93..ba19430dd4ea 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -794,7 +794,7 @@ static unsigned int alloc_swap_scan_cluster(struct swap_info_struct *si, if (!cluster_scan_range(si, ci, offset, nr_pages, &need_reclaim)) continue; if (need_reclaim) { - ret = cluster_reclaim_range(si, ci, start, end); + ret = cluster_reclaim_range(si, ci, offset, offset + nr_pages); /* * Reclaim drops ci->lock and cluster could be used * by another order. Not checking flag as off-list