From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F87AC433E0 for ; Wed, 27 May 2020 20:54:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05EB12088E for ; Wed, 27 May 2020 20:54:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gY23dNqi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728620AbgE0Uyl (ORCPT ); Wed, 27 May 2020 16:54:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726718AbgE0Uyk (ORCPT ); Wed, 27 May 2020 16:54:40 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AA46C05BD1E for ; Wed, 27 May 2020 13:54:40 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id x18so9515497pll.6 for ; Wed, 27 May 2020 13:54:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=0PiLFUHjJ3TV2xcfUTcBbUSBMI/CnZK15s/joy4TG+Y=; b=gY23dNqiZtCL+lz80go6c7oVIXjBIhyhcV2JSOZV4pqRf79boVoadZBc4SIKj2+Xu1 k1Ns6Qh3ueAFxQuC4HWqhwfJ57/Qnx78BDrFrwFdXQZg/uC14VrdMJ5bfoLlXq4lc4BV CjAvdb2YYuf9B7aArvsqJE2RQBEQTwx2WMbWx2Gc64mnUFfirkcnl6sR8T/Udl08Xpo7 yz03yC4GNLHTD1/+l4dcQNRXyGHw79LAHLoLCMxtFjDfq/kJD16FL3skM2ujZtZLKMOT GV0DKUO6KtSTxzNts1+hVNYkeijJDhV9/a0t+v1iL3rFILT4FiEdxTkpfezgnJNO5ANv wn9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0PiLFUHjJ3TV2xcfUTcBbUSBMI/CnZK15s/joy4TG+Y=; b=R65usBxuJKiHCwEy5y2npK3bD/hGaH+B+DYKa2etPdVAK2LPK4mV3S9EocnRRWYvF9 r1vbawiSQ1HYr4R9ZMS3G9xy0R7G0hbryCcPyMj/I6DqJ1VdUE/9XYTJm09+pfqqSr0x Af7iVrrhUdckLuFzasDNDs8/VVEpL2Nky3LmIe2TgyyjQtv4EpHXAp69gE9Zvb7ASz0W PLpPbgtlOi8vMLtZJSF8zWBHY31hA6kPzfOYkwVhyo1DDKjYmd+SS6P+2SyW2SM51tzW V/gqv0ls2bMHuZWz8Sw4AqbkyRMOzwXSafq8JWqDWlralB+NvVzQNZLdRuZxpgZnhtwy BdBg== X-Gm-Message-State: AOAM530buuGoP1Iyuj4C08vSJ7UCzs+6w7g+wAEiBKcN6YFEuhKlbkYL asU5vucngZ9SSz/HedokA3g= X-Google-Smtp-Source: ABdhPJwV8OJTbrEJlcXxHa5WpihgHyU1h/uvcIml2IOtVxTmnKMbONosMFdkhG4t36EX7+JYvOXFWA== X-Received: by 2002:a17:902:b203:: with SMTP id t3mr213803plr.129.1590612879611; Wed, 27 May 2020 13:54:39 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC.domain.name ([122.171.201.5]) by smtp.gmail.com with ESMTPSA id x12sm2895477pfo.72.2020.05.27.13.54.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 May 2020 13:54:38 -0700 (PDT) From: Souptick Joarder To: rspringer@google.com, toddpoynor@google.com, benchan@chromium.org, gregkh@linuxfoundation.org Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Souptick Joarder , John Hubbard Subject: [PATCH] staging: gasket: Convert get_user_pages*() --> pin_user_pages*() Date: Thu, 28 May 2020 02:32:42 +0530 Message-Id: <1590613362-27495-1-git-send-email-jrdr.linux@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This code was using get_user_pages_fast(), in a "Case 2" scenario (DMA/RDMA), using the categorization from [1]. That means that it's time to convert the get_user_pages_fast() + put_page() calls to pin_user_pages_fast() + unpin_user_page() calls. There is some helpful background in [2]: basically, this is a small part of fixing a long-standing disconnect between pinning pages, and file systems' use of those pages. [1] Documentation/core-api/pin_user_pages.rst [2] "Explicit pinning of user-space pages": https://lwn.net/Articles/807108/ Signed-off-by: Souptick Joarder Cc: John Hubbard Hi, I'm compile tested this, but unable to run-time test, so any testing help is much appriciated. --- drivers/staging/gasket/gasket_page_table.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index f6d7157..d712ad4 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -449,7 +449,7 @@ static bool gasket_release_page(struct page *page) if (!PageReserved(page)) SetPageDirty(page); - put_page(page); + unpin_user_page(page); return true; } @@ -486,12 +486,12 @@ static int gasket_perform_mapping(struct gasket_page_table *pg_tbl, ptes[i].dma_addr = pg_tbl->coherent_pages[0].paddr + off + i * PAGE_SIZE; } else { - ret = get_user_pages_fast(page_addr - offset, 1, + ret = pin_user_pages_fast(page_addr - offset, 1, FOLL_WRITE, &page); if (ret <= 0) { dev_err(pg_tbl->device, - "get user pages failed for addr=0x%lx, offset=0x%lx [ret=%d]\n", + "pin user pages failed for addr=0x%lx, offset=0x%lx [ret=%d]\n", page_addr, offset, ret); return ret ? ret : -ENOMEM; } -- 1.9.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87BA4C433DF for ; Wed, 27 May 2020 20:54:45 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5C68D2088E for ; Wed, 27 May 2020 20:54:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gY23dNqi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C68D2088E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 2E55188A29; Wed, 27 May 2020 20:54:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RVe3TiLnXMqA; Wed, 27 May 2020 20:54:42 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 85F6F88A13; Wed, 27 May 2020 20:54:42 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id EEF9A1BF591 for ; Wed, 27 May 2020 20:54:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id EB6BB87F7F for ; Wed, 27 May 2020 20:54:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P3S-983opkXG for ; Wed, 27 May 2020 20:54:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by whitealder.osuosl.org (Postfix) with ESMTPS id 2A8BE87F6A for ; Wed, 27 May 2020 20:54:40 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id a13so10646036pls.8 for ; Wed, 27 May 2020 13:54:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=0PiLFUHjJ3TV2xcfUTcBbUSBMI/CnZK15s/joy4TG+Y=; b=gY23dNqiZtCL+lz80go6c7oVIXjBIhyhcV2JSOZV4pqRf79boVoadZBc4SIKj2+Xu1 k1Ns6Qh3ueAFxQuC4HWqhwfJ57/Qnx78BDrFrwFdXQZg/uC14VrdMJ5bfoLlXq4lc4BV CjAvdb2YYuf9B7aArvsqJE2RQBEQTwx2WMbWx2Gc64mnUFfirkcnl6sR8T/Udl08Xpo7 yz03yC4GNLHTD1/+l4dcQNRXyGHw79LAHLoLCMxtFjDfq/kJD16FL3skM2ujZtZLKMOT GV0DKUO6KtSTxzNts1+hVNYkeijJDhV9/a0t+v1iL3rFILT4FiEdxTkpfezgnJNO5ANv wn9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0PiLFUHjJ3TV2xcfUTcBbUSBMI/CnZK15s/joy4TG+Y=; b=otvW04CD5ioivdUNAI5iHGgRbGq7ZIXu8miby9ktXKpapP0WlJ2UnbXhX1zTeiR06u gY6hDy/qlxeABeTTmpnB83009X3ae3b4ubBgrASXqc4ys7a0dJYcrJp0dCjmOIWEKbfr TJuyjkD4p1ekd2mCx1TqMfm4K7+RN35WdXuJBDkI7sO6TWCI2D+o9h5GgWL3pEdezWSd w6nzksU9OuVgsfyICemy1mEIkM/zfJRZP8xEb8CC2NMcAJJgFo02wVKg/CTTTy0oKa++ 3L0Jd8mI/gDeB1T42BiXTUyXY2ZhaVNSjODZGzLDJ+dRCdLkDMheHyQF5BEfZG5lhj0T jNfQ== X-Gm-Message-State: AOAM530p4MqWXn7R4CyRjs2PmJlBuzE3YpO57tjxMwIZaLjVoNFTG3Rb btJnkQbF3/esjeJH0PVyd1c= X-Google-Smtp-Source: ABdhPJwV8OJTbrEJlcXxHa5WpihgHyU1h/uvcIml2IOtVxTmnKMbONosMFdkhG4t36EX7+JYvOXFWA== X-Received: by 2002:a17:902:b203:: with SMTP id t3mr213803plr.129.1590612879611; Wed, 27 May 2020 13:54:39 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC.domain.name ([122.171.201.5]) by smtp.gmail.com with ESMTPSA id x12sm2895477pfo.72.2020.05.27.13.54.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 May 2020 13:54:38 -0700 (PDT) From: Souptick Joarder To: rspringer@google.com, toddpoynor@google.com, benchan@chromium.org, gregkh@linuxfoundation.org Subject: [PATCH] staging: gasket: Convert get_user_pages*() --> pin_user_pages*() Date: Thu, 28 May 2020 02:32:42 +0530 Message-Id: <1590613362-27495-1-git-send-email-jrdr.linux@gmail.com> X-Mailer: git-send-email 1.9.1 X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, John Hubbard , linux-kernel@vger.kernel.org, Souptick Joarder MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" This code was using get_user_pages_fast(), in a "Case 2" scenario (DMA/RDMA), using the categorization from [1]. That means that it's time to convert the get_user_pages_fast() + put_page() calls to pin_user_pages_fast() + unpin_user_page() calls. There is some helpful background in [2]: basically, this is a small part of fixing a long-standing disconnect between pinning pages, and file systems' use of those pages. [1] Documentation/core-api/pin_user_pages.rst [2] "Explicit pinning of user-space pages": https://lwn.net/Articles/807108/ Signed-off-by: Souptick Joarder Cc: John Hubbard Hi, I'm compile tested this, but unable to run-time test, so any testing help is much appriciated. --- drivers/staging/gasket/gasket_page_table.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index f6d7157..d712ad4 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -449,7 +449,7 @@ static bool gasket_release_page(struct page *page) if (!PageReserved(page)) SetPageDirty(page); - put_page(page); + unpin_user_page(page); return true; } @@ -486,12 +486,12 @@ static int gasket_perform_mapping(struct gasket_page_table *pg_tbl, ptes[i].dma_addr = pg_tbl->coherent_pages[0].paddr + off + i * PAGE_SIZE; } else { - ret = get_user_pages_fast(page_addr - offset, 1, + ret = pin_user_pages_fast(page_addr - offset, 1, FOLL_WRITE, &page); if (ret <= 0) { dev_err(pg_tbl->device, - "get user pages failed for addr=0x%lx, offset=0x%lx [ret=%d]\n", + "pin user pages failed for addr=0x%lx, offset=0x%lx [ret=%d]\n", page_addr, offset, ret); return ret ? ret : -ENOMEM; } -- 1.9.1 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel