Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1363955rwl; Thu, 5 Jan 2023 12:28:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXtt7IIdyFvryOLhXmU7gnd4AtQV+7MajbYbbDGnlfapibI1NyjEpewnOXNgmwnAj7ha40fM X-Received: by 2002:a17:902:aa0b:b0:189:cb96:1529 with SMTP id be11-20020a170902aa0b00b00189cb961529mr48308953plb.44.1672950484220; Thu, 05 Jan 2023 12:28:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672950484; cv=pass; d=google.com; s=arc-20160816; b=Neu3m6c7Xbszu9txTwPrNWW40kXdVmFrbTTXlV5wzuI168X3BqkKgnE4TtfdA229gN tTpQmqUrcAdLrDk+AiLoHAUQtXncVREflozzX3G7NjGb0KqRz+WDDCyY1F86dPbLLbnu +8jwoY0RyXlejTzM+ldRYQzCqSO/3xiZiwPvNZK9O51ooTO0mjgGl0sQpZhvxqZ/Rw/H GfqfNrLg3TZRi0t1trPoVcYqEj5VFCe9ACT7qhHwKtJ5m0WMZinmYMUQpQpteVIECOJ6 q3T5XQb/+pIOkWVrwseDgH1IIBIz71LZvJ8MmRu//R84GCQwIWgyomNEACyrFyuw+nCD NcZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=706I8s8ymPJmB1LjWd5YnsxEYFLwL1h6V+UbCNHhDqU=; b=GZWNTURFyEfbhLrbActbJengorT49NO/Jc/lA7KHjI4a5/MAUGzo3JhlgNZ3unbasN F2tCPdZLs3GVEakHmcIB0g7sWU0JrXE7+HMP8+VAh5VLUmu6g469TWBjzCoWle5Nl+6q M9r4QPyHXJa2DD4FGBf2aUzzTZxVFl3ER6SCUB3atp5nAXcYz1A7etnLc32jftm5VHrL dkRPsOFpu0pU8YDrUuFLzx8irMRgZN2ItXSEaHl4ni7bz3kUe5Xf8oWgQiIvYlCBG+PW V1FCzS7/vi3aABW8EHLXtsyZDwglSyNziDWZQhiOlh2CIq5HhHJnZ+4EUhP3x3ZheITu 6mvQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=aWaGQBJD; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w17-20020a170903311100b00186e9ff4edcsi35908473plc.408.2023.01.05.12.27.57; Thu, 05 Jan 2023 12:28:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=aWaGQBJD; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234830AbjAEUZz (ORCPT + 55 others); Thu, 5 Jan 2023 15:25:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231523AbjAEUZw (ORCPT ); Thu, 5 Jan 2023 15:25:52 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2049.outbound.protection.outlook.com [40.107.92.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F80F15F24; Thu, 5 Jan 2023 12:25:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j6Ajz1JbGOi8ttVzjaZAGefGKyWIZt0gcaCR6kO+k8YkF2hDeDfQbCV/daSRPW3BdnmnDy5eTGhs0ft6NvXRy5F3q5dMZpz/043IR3Z8Shg619czPtQdvFyqw9evcCsNk4ycxHxPxA4OFjQOYDJ1UWblngmuFdvPxbYDQw8S8Q5ANPV76oXiSpDDpotTOqxypVeCkJXpKW95EqZLcKEfYdNmzsPaLsLcs6eiUBYW7c9rsbEul6jUlpA304FTIAl+f/3MRVcbPz7VGqwVRodvpojo7wB6gJNZxQpo4gOuo6J0sOfyf4GHF4eWv2aYJdnMD2hkew88dKDbuWZfjRHZpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=706I8s8ymPJmB1LjWd5YnsxEYFLwL1h6V+UbCNHhDqU=; b=jKQAp+Vv4OSA5iHhKUjL13G3TV+sS26ZkbklreDJNTQrm1v4uqjoDvOmLUnXbg8vbT3vqNBr29sxOFk1bOI+IhkeYVNY3yi6BP1nVZGUcdmWh/3E2DzVLWO70idgG7WH7BKY+nPewKM3oq6YOo30AcdnOBM24T5DSRAJ17Ypk6XBurLdTIGXN5cKpRRuoLi2Sdb6HMF007xeC6in/P2e/95mMgOogeqpd7N/sx+5sC+TyFKxAamm8AyrPuQfJGcghzeE3apxqBBCAuS3Re9hT1Tv1wCvXkJ9uA4CGMnYWsnTWIb8e4WNvhdUSTXwO/LP2XK1ngVgsx6y692lQzu7Gw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=706I8s8ymPJmB1LjWd5YnsxEYFLwL1h6V+UbCNHhDqU=; b=aWaGQBJDeVqC8TAY17bd/D/s07O0BWhJcVvfZ6vuD4lDv/K6aiylQqQs3Ytymr785Uf15eEgT/BfroHhE+uHLWnnZFYgj2w6dJX8FS7aH3xjUj0ir6ZsCkw8tm9Y/Y1BblSlV274KYOQJ0uDfkK8zcnkr+ddNtusS2hGL1DjUdgcoqY+HOS2kQEaZB2xmg0OZ6rEB7Imc0JjJrEXNLUKSUwQ/fn3SiC0XfxgHN8O5ncceOsGYCny2TqrdxZ44qN7jZJkpYp0ONWIoRXp/F0+X0QeEBCndZLizb3ilg2XZVz/EzJN0n7q9NKSi+d2D/YM0k9N0bKr6dxnP5aMwATWTQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA1PR12MB7365.namprd12.prod.outlook.com (2603:10b6:806:2ba::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 20:25:49 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 20:25:49 +0000 Date: Thu, 5 Jan 2023 16:25:47 -0400 From: Jason Gunthorpe To: Logan Gunthorpe Cc: Yishai Hadas , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org, axboe@kernel.dk, hch@lst.de, alex.williamson@redhat.com, leonro@nvidia.com, maorg@nvidia.com Subject: Re: [PATCH] lib/scatterlist: Fix to merge contiguous pages into the last SG properly Message-ID: References: <20230105112339.107969-1-yishaih@nvidia.com> <81470f28-2bcf-b3cc-4824-6e45343dbd77@deltatee.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <81470f28-2bcf-b3cc-4824-6e45343dbd77@deltatee.com> X-ClientProxiedBy: BL1PR13CA0114.namprd13.prod.outlook.com (2603:10b6:208:2b9::29) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA1PR12MB7365:EE_ X-MS-Office365-Filtering-Correlation-Id: 70710f88-7168-4901-6135-08daef5b088d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SeoJIWXLpI6BKSNKFTDgERiVm4O56TI6BoSDe+18CkZeHSMMghXeCLObod2bD5y4Mb6cZf+aWg6wC1oX01EONzxUt76wuB0B9Hb1sDW3qr27QQWNVgsJxQ3Oo7xIUM2nVpFa+4Kc+8AoquHSE3KvefNzjl0HATzrGZNLKZDSc9M1Htj984X3rTwFSrfRU+rFdhqFuxZQBTmfpbtHvRr2Ww8T5QgzZjp63rVdO5Q497Ra4YGodPmIFtuvNmrtiCf62aPJunp3qYiDWWoJGGVaIYsCpnZtRmCxSO69iI7Jw12gjor8fcBzELbZT9Ci8gyMxTiBO7tSQP5lGGsqw/bavnxOZdVPxvjC4NqQGLNqMZI1RhsFYaZGbUc8WYZ7pDlQ9I7/pz4wKXV0iWseMLs6a5SatuyoW8u3BU6tb1DjE9WnN/gZ2k3MrbZ7rS34ObV4ajMQaoeY2soQLRLoUDWwax9nFLD5rQS/JggnPk1YUYusWdJEathfBW0L6W+LIp8nO7sdWJP32llFYNO87dt2a7X8s+QNg7CSkRJSO7Fm5g71JpyyQzgPqIeO4hvI+M96CcfEsa7SRdtUuROOoTQRcbaSpBctvDTAip7PG2AoKfp78iiszkAxwes0UWUzlm4VCLUJP3tH6k1PV2xaP5Og3yBWM+gSlwYKHhApH+g/OAmvFRrAML1d2wid8x7aJYDvMUlmaprszTfm/Y/JY7nqHy/TMPOHP7eCtbtJ487x5+o= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(136003)(39860400002)(396003)(366004)(451199015)(26005)(186003)(2616005)(6512007)(83380400001)(36756003)(38100700002)(316002)(6916009)(2906002)(66946007)(4326008)(41300700001)(86362001)(8936002)(5660300002)(8676002)(66476007)(478600001)(107886003)(6486002)(66556008)(53546011)(6506007)(966005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Hs4IsYyB9PVA1gLwwWE1F729cdcIAWOsmsLC7heFVAi6G0Tw6J4okKhbIog9?= =?us-ascii?Q?RCI5WwmGuxsvLx01fcjb2IwJepUQkYWOTjyCTXmmKcbcYQf8j2CsiMhvx3o3?= =?us-ascii?Q?zhaDD+2KKRXuuJTGISHoszK9QsxoImxY7CUsBasWeoB1Sk6oFGm9b/w6CkXZ?= =?us-ascii?Q?vuFlKf2cEVa2XZ2pVmGA6mi1jH08GpA7JJ/82O+gDOljDMDymcJwpw/qb6M7?= =?us-ascii?Q?1PBV2rh3lvVmwVxUuN9Gv+Zzgcs9YGiLHm9ybFL9/I8csyktMu4yrNn0CwFu?= =?us-ascii?Q?q3IxxGSwUFNP7oD7LBaPfDcWLRg9qVFxK945gMyUaf3lCql6t0r6nvTRy4HL?= =?us-ascii?Q?4k3aOJzwAwdYpMzej0v7U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?Q?lTO9KyS5EG81ma5N8xxzHYbBZwcvvo+Ako5n5Wzw/7sw8mVvO/5e/7+iugIs?= =?us-ascii?Q?FnjEUaKJPoAHJ2Ffl2rBSru+yPGiB/GWACp/L2XBr0JE6Rj0iFJEbcXRCANV?= =?us-ascii?Q?PfJD+AXrM+2FHSJqkD1h91Se4nL+B/+1ekuv67UtU9oH8Z/w8faB1AWdhV88?= =?us-ascii?Q?+a2mtJOlttDQvfoUt3kwo/vopMHIMo+L+K4VxNSu70a5ehzGQPYGm/WzWT4g?= =?us-ascii?Q?1LYRYDysOVUxY2H3zUo/zW/2UBNkyzUqzyABrb3XbqjBU/doNt4x5BCujRaz?= =?us-ascii?Q?xGHOvWuX6qpJINGwT00WrYhf+Gpw/q9aVVPj6f+I?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70710f88-7168-4901-6135-08daef5b088d X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 20:25:49.2310 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gsmP4k4CVXkL9J676r9eSE+QWkLxy6DlET2+N8ja4+/4ZmT+KhAEe21J+O4DtDpT X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7365 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 05, 2023 at 01:23:52PM -0700, Logan Gunthorpe wrote: > > > On 2023-01-05 13:06, Jason Gunthorpe wrote: > > On Thu, Jan 05, 2023 at 01:23:39PM +0200, Yishai Hadas wrote: > >> When sg_alloc_append_table_from_pages() calls to pages_are_mergeable() > >> in its 'sgt_append->prv' flow to check whether it can merge contiguous > >> pages into the last SG, it passes the page arguments in the wrong order. > >> > >> The first parameter should be the next candidate page to be merged to > >> the last page and not the opposite. > >> > >> The current code leads to a corrupted SG which resulted in OOPs and > >> unexpected errors when non-contiguous pages are merged wrongly. > >> > >> Fix to pass the page parameters in the right order. > >> > >> Fixes: 1567b49d1a40 ("lib/scatterlist: add check when merging zone device pages") > >> Signed-off-by: Yishai Hadas > >> --- > >> lib/scatterlist.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > > > > rdma is pretty much the only user of this API and this bug is causing > > bad data corruption, so I'm going to take it to the rdma tree and send > > it tomorrow. > > > > Which raises the question why the original patch was done at all, > > nothing ever inputs pgmap pages into this function? > > It was done solely because you had suggested it was necessary. > > https://lore.kernel.org/all/20210929224653.GZ964074@nvidia.com/ Yes, but that was when I was expecting this would work with FOLL_LONGTERM and PUP.. Jason