Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp747021lqb; Wed, 17 Apr 2024 09:31:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWNneLzzUEupMoy1tSDgpRMTaPD0dnllAw6utM9pvFhvdlfjvK80S4Re2B22nwNiiPSGNXnKu6NtB9QULvAGG/uFh9Gxc7g4bO/Jbun5w== X-Google-Smtp-Source: AGHT+IGt/a8VV2cFt8HsmJH+KRB2bdVWbBiHVQpMTqOGo02IbQeKu7lOAe/VSkEp1vSuXboPpf6P X-Received: by 2002:a05:6a20:1583:b0:1a9:9664:ef12 with SMTP id h3-20020a056a20158300b001a99664ef12mr148054pzj.43.1713371470429; Wed, 17 Apr 2024 09:31:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713371470; cv=pass; d=google.com; s=arc-20160816; b=rxiE6eE4zVSsSsiXk4tTEcXEpTfpAabk6HP0VQRxrLF3dyCHxV7cd1wa4rB5fY96yr NdSTKq+nxEJmNUHSueurE7PKDo4KNgNLt/+7CLV7i8vaIongU3x0YIU5Sz3YjT9BhjkO f8Il/gmTaXmuJii9c4IpaoE88t1J15h3HNaVt3fkNjKamOsIl+DAuzJUOk9LCckqhamQ ha2E+ch3iamJnq71Rf9+eat+vKX/185P4UJv5QDHRbm4h1HzSudkyAEBKzEsbAmMip9z klI69hnMBlmIIZCXN4h7EjDf9yiAiQMHpY6yWccCnPqax/Jdam+NCInUtBZxg3aAWvkO yiLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Srg4dA9RNSDxQazS93yF50nbI2bCxfJ5XfNZ+0IFk1c=; fh=8UN2lTe9sS55RErFImRW3hzpKvubx94fzeetl21HTKA=; b=UVhnG+CnUJWadsUTn9uvkxSwKtNppNuXWauDFFQcaPlM7bw5HF1BPWHvJ0RhJNq//Z +lWS5wgdgEE0ZS1sDg3OZML3aD0U+qWcuq64SyaXgG9GOku7pT4sPKADNFw9FM3txdEh NlQPNHrP/vdR8pFfBQeVBerB7O0G8JYMXYfzPw7N5sb3Yz9NtTR81/8vR3osi0rIyRC8 O5hKL6uNSbsyiKaQNbAM0BrwzaulIkrMSeAkBQEJSqacJF2AQP9i5hWWU6i0Gh6cPQ8u UIAD8IMxcJqLoprAzgfodOpT+OG2PIM7KUHXiUt9oO2o3MyWHmE/mOqVYoa12RX8HRTK Ng3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aowM79hZ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-148882-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148882-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 8-20020a630f48000000b005f3a866cc50si11583133pgp.550.2024.04.17.09.31.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 09:31:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148882-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aowM79hZ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-148882-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148882-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 27EF9B24601 for ; Wed, 17 Apr 2024 16:11:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2254715E214; Wed, 17 Apr 2024 16:10:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aowM79hZ" Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A10B15E200; Wed, 17 Apr 2024 16:10:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370209; cv=none; b=GkAvRT+/+BxHtML5IHEi3XkF28IrFyVD6fWmLXIW26YaWyyZt1d+D88syOuhOUalyBKon2Bd9gNFRzVspdb0wPSpD+Mam1wZhfI8/tOP9F33nOvq/LuM+bu5bUQaJ7lOtFrP1UQyqiVN18IJP8jN2bZXgZeZZWwW0oa35CUDiRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370209; c=relaxed/simple; bh=Z6E2pCl6gh7/PPQWEZWXuOAcVWTT82yYaNSwyTRO5yg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AXqif7ruL/oEutgjEkgcf4RGMGpEAbfwh7LNhSMEskEWpgFzOj5aVu0YsbnqdUvMyDKrVBRoMEiuS914oYQdRpzSu7RqwGLcuQGl/IhehFFUUJqJ/pHbHhJEvAtGqTiSB6vRHCgQ06d91N5xSXkgdA2/txjGznumhkAdzv45YOQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aowM79hZ; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6ead4093f85so4895104b3a.3; Wed, 17 Apr 2024 09:10:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713370207; x=1713975007; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=Srg4dA9RNSDxQazS93yF50nbI2bCxfJ5XfNZ+0IFk1c=; b=aowM79hZL9Ruw+wtsOLqgQPAhm4DjRKPKSwAhaHaMJzDnNWVyyQyAcnhXEQo8bDP9v sOKFhgllOodLknAFGJjEuprMnW8IlfpzybMwPrzvuQSL0ww3wgOuh1Rt8H4xmjFkFWfk WMn9RDotpQ8gonm3ArqVn2M97R4wGL8/ISE5GBp16nxtW9nOnE0y2OAeYkLGlElYtmru uJoUUGqnmoEJXFy3NdPPFRG1swlY/XYLGhduMFrfjrwwpm1FG8wVo+s6ASN8rUvy69Vf voEdPNj0JhwV4uNtjpULgWDafF/2spBjuoxm64lX/u+QxEc/637hQl5lP45dpXh95/nA lxTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713370207; x=1713975007; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Srg4dA9RNSDxQazS93yF50nbI2bCxfJ5XfNZ+0IFk1c=; b=bQKTN38OyqV7NyvR3FKSa0or3LwsP9jTrhUfz3Wqgl8WHDGNnj5NuQmNvxBLOLmZea sSh0Xx3GCtFCpeptcz+sXnXbDojMmUpn/nvXCu4c/sD0hyOfofTtqGuyqn/6QCe1sPMt igQPBz7IVwGw/rNw0gYCkCmas8xCou3h8oGOeZWJFcRZlvFlzESt1Aa80dwsMke8zTqh YAnUDYqnJq49umB+0lNDBQ7DdFxdayhE4WBsx5ermpZifPp1pEo1OTWFEkJMy7Iqz3vr yAcrrTW5/0Dm7BkeLnXB0vQvrU7DVaweQ3c6W6YU3lbW7eOsCSB1fKM+fHHvLWKmIk/e yNIA== X-Forwarded-Encrypted: i=1; AJvYcCVGymZQd9t7MKzwyWaDArZ0KY3/l31ZN1EYfTf8f9Y8ZtSR9K6rnCvDa0gkcTRbR7jrKnBNtd+/vzhVqDnqQ30TmAtxiVDlUtK2lQJik5zVSM1fq07SQS9Q9zRDvteSou8YjriLYuLWxyXGYA== X-Gm-Message-State: AOJu0YzJbwV1SlX/45pxCzMcoQCHXizoFDw2kI5e27X6WTJ02hc9hgJh MMnjzCOxvD+a2HJJEL2CJMvq8VtbT1EDWYivBC75wME+30IsrYNm X-Received: by 2002:a05:6a20:3ca4:b0:1a8:2cd1:e437 with SMTP id b36-20020a056a203ca400b001a82cd1e437mr102832pzj.11.1713370207249; Wed, 17 Apr 2024 09:10:07 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([115.171.40.106]) by smtp.gmail.com with ESMTPSA id h189-20020a6383c6000000b005f75cf4db92sm5708366pge.82.2024.04.17.09.10.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Apr 2024 09:10:06 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , "Huang, Ying" , Matthew Wilcox , Chris Li , Barry Song , Ryan Roberts , Neil Brown , Minchan Kim , Hugh Dickins , David Hildenbrand , Yosry Ahmed , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH 6/8] mm/swap: get the swap file offset directly Date: Thu, 18 Apr 2024 00:08:40 +0800 Message-ID: <20240417160842.76665-7-ryncsn@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240417160842.76665-1-ryncsn@gmail.com> References: <20240417160842.76665-1-ryncsn@gmail.com> Reply-To: Kairui Song Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Kairui Song folio_file_pos and page_file_offset are for mixed usage of swap cache and page cache, it can't be page cache here, so introduce a new helper to get the swap offset in swap file directly. Signed-off-by: Kairui Song --- mm/page_io.c | 6 +++--- mm/swap.h | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index ae2b49055e43..93de5aadb438 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -279,7 +279,7 @@ static void sio_write_complete(struct kiocb *iocb, long ret) * be temporary. */ pr_err_ratelimited("Write error %ld on dio swapfile (%llu)\n", - ret, page_file_offset(page)); + ret, swap_file_pos(page_swap_entry(page))); for (p = 0; p < sio->pages; p++) { page = sio->bvec[p].bv_page; set_page_dirty(page); @@ -298,7 +298,7 @@ static void swap_writepage_fs(struct folio *folio, struct writeback_control *wbc struct swap_iocb *sio = NULL; struct swap_info_struct *sis = swp_swap_info(folio->swap); struct file *swap_file = sis->swap_file; - loff_t pos = folio_file_pos(folio); + loff_t pos = swap_file_pos(folio->swap); count_swpout_vm_event(folio); folio_start_writeback(folio); @@ -429,7 +429,7 @@ static void swap_read_folio_fs(struct folio *folio, struct swap_iocb **plug) { struct swap_info_struct *sis = swp_swap_info(folio->swap); struct swap_iocb *sio = NULL; - loff_t pos = folio_file_pos(folio); + loff_t pos = swap_file_pos(folio->swap); if (plug) sio = *plug; diff --git a/mm/swap.h b/mm/swap.h index fc2f6ade7f80..2de83729aaa8 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -7,6 +7,11 @@ struct mempolicy; #ifdef CONFIG_SWAP #include /* for bio_end_io_t */ +static inline loff_t swap_file_pos(swp_entry_t entry) +{ + return ((loff_t)swp_offset(entry)) << PAGE_SHIFT; +} + /* linux/mm/page_io.c */ int sio_pool_init(void); struct swap_iocb; -- 2.44.0