Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp981232pxb; Fri, 22 Apr 2022 15:52:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlKEXkU0FP3RqJ23z5AVX4hXcCDW9MeAXs8hrVClMdukpfn31TJNeFvYdPIVblatzu4sq5 X-Received: by 2002:a17:903:2406:b0:158:72dc:2d73 with SMTP id e6-20020a170903240600b0015872dc2d73mr6838721plo.46.1650667979646; Fri, 22 Apr 2022 15:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650667979; cv=none; d=google.com; s=arc-20160816; b=Fjo0+kxkSBEVcPn7h3RlR1cMLJj8dUXVGjb/VKVBHYQJaJ49YJc4PAgmPSqVY7NVL3 pX2fsZaTLfZ/cmdrxOu8LvKQTSYg27WsmL9XBI49hAxeRwGbVIoRyHUocrlTxd3c/ZTl 4C+Qm5+iI2DxoapIASL1IMZ7QHd59oX9pL+ZPyBzx56izQZjHvb2t+Zr/bLV0xl7v32H HLsS72orYA+B7zra+YE7OFJB1rHm44o2MuQa+jMorCKZXei8ZhxK4RVVRYQ0qvIqkrHP /7pmRNNjPHDxy5nefN2wlk5gJ1sQHTtgMQYhxtQuKZgD4LTWSnNhWgjDjOsDbF3dLgEd rtqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=9I3bT6dcN2vCZLdK2K7miTQFQ1CYOstV5pWjpPiUb+Y=; b=TadGzwGG6GoSSxzyb95JWR2V6z9as/ylQJPGKrx8lfzW2FHSjbxfB1X0pDhhPOrXu1 fNyevQoRHS0v/sg+pd1gjVG87YMNHDUD6nHimRsAvwDNcRD36yVzRN8dAgHZjDOCyH9O NZdigicBsVVAdM03lbLZsg3KppCvq98KE1lb/+MMdiYGvwhbTNaszsEK5pI6U50xKXXy R3xbA64cufjQQLg1RazyQMVtvEH93IX9Mg0SSo7JjQgRjD53V9vYBLdp6DDV/aBIW/oC bd8u1YF7RVtPasZLYODhwasyJggsqWMo7DZCJ/Di36hR00QvGfElTXVgmTtv0aA+Vcnr A5Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=WNZyopOq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b3-20020a170902d50300b00153b2d164b1si10490595plg.185.2022.04.22.15.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 15:52:59 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=WNZyopOq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 677482697AA; Fri, 22 Apr 2022 13:43:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378623AbiDTNnB (ORCPT + 99 others); Wed, 20 Apr 2022 09:43:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354000AbiDTNm7 (ORCPT ); Wed, 20 Apr 2022 09:42:59 -0400 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 420533EAB1 for ; Wed, 20 Apr 2022 06:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=9I3bT6dcN2vCZLdK2K7miTQFQ1CYOstV5pWjpPiUb+Y=; b=WNZyopOqnJxaQ0EhlQcHhCW6rNA0BpnSUqA0bIJDlbTQEM3Rt2Cdovry Tutni1e+2r9GTbhxHgPRi8GoQGNbn11m+/rdD/n/BRa1s4Wzw9FP785jj ys0FAO5f9ksBA0jBF9qSnnCdQEI6Fv4lliFLxxLcUZLBl5iqvKjU2Yv+0 I=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="5.90,275,1643670000"; d="scan'208";a="32527674" Received: from 203.107.68.85.rev.sfr.net (HELO hadrien) ([85.68.107.203]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2022 15:40:10 +0200 Date: Wed, 20 Apr 2022 15:40:10 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: "Fabio M. De Francesco" cc: Julia Lawall , ira.weiny@intel.com, Alaa Mohamed , outreachy@lists.linux.dev, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] xen: Convert kmap() to kmap_local_page() In-Reply-To: <2940450.687JKscXgg@leap> Message-ID: References: <20220419234328.10346-1-eng.alaamohamedsoliman.am@gmail.com> <2940450.687JKscXgg@leap> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1715972237-1650462010=:2937" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_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 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1715972237-1650462010=:2937 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT On Wed, 20 Apr 2022, Fabio M. De Francesco wrote: > On mercoledì 20 aprile 2022 08:03:05 CEST Julia Lawall wrote: > > > > On Wed, 20 Apr 2022, Alaa Mohamed wrote: > > > > > kmap() is being deprecated and these usages are all local to the thread > > > so there is no reason kmap_local_page() can't be used. > > > > > > Replace kmap() calls with kmap_local_page(). > > > > OK, so from a Coccinelle point of view, could we do > > > > @@ > > expression e1,e2,x,f; > > @@ > > > > e1 = > > - kmap > > + kmap_local_page > > (e2) > > ... when != x = e1 // not stored in any location and not passed to > another function > > when != f(...,e1,...) > > when != x = e2 > > when != f(...,e2,...) > > -kunmap(e2) > > +kunmap_local(e1) > > > > julia > > > > I've never spent sufficient time to understand properly the syntax and > semantics of expressions of Coccinelle. However, thanks Julia, this code > looks good and can be very helpful. > > Only a minor objection... it doesn't tell when 'e2' has been allocated > within the same function where the kmap() call is. > > In the particular case that I cite above, I'd prefer to remove the > allocation of the page (say with alloc_page()) and convert kmap() /kunmap() > to use kmalloc() / kfree(). > > Fox example, this is done in the following patch: > > commit 633b0616cfe0 ("x86/sgx: Remove unnecessary kmap() from > sgx_ioc_enclave_init()") from Ira Weiny. > > Can Coccinelle catch also those special cases where a page that is passed > to kmap() is allocated within that same function (vs. being passed as > argument to this function) and, if so, propose a replacement with > kmalloc()? It looks complex in this case, because the allocation is in another function, and it is passed to another function. julia > > Thanks, > > Fabio > > > > --8323329-1715972237-1650462010=:2937--