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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF113C77B76 for ; Fri, 21 Apr 2023 00:41:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D425900003; Thu, 20 Apr 2023 20:41:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28420900002; Thu, 20 Apr 2023 20:41:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 14BBF900003; Thu, 20 Apr 2023 20:41:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0576C900002 for ; Thu, 20 Apr 2023 20:41:29 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B785580791 for ; Fri, 21 Apr 2023 00:41:28 +0000 (UTC) X-FDA: 80703544656.01.1400AFD Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf30.hostedemail.com (Postfix) with ESMTP id DB9AC8000C for ; Fri, 21 Apr 2023 00:41:26 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=tG404iTe; spf=pass (imf30.hostedemail.com: domain of cmllamas@google.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=cmllamas@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682037687; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=V9j1g7sK3q1/d39/yJUozMObHifrV7DZPVY+c2FKrBI=; b=Wh9sYPuySNDxEZ7tlq6yeB3zmLkc+YpLekYq6Le1wZ+No+Vd1WX2qD6NTWWx4cCX6uJSEz mB7x1E2o/pFVERzbhawOPbTWgCA945TsDl2GRTcqGKm10CDDlX+kQQKg4C3wzgmr5oYN5J iFiBTZnAU8QLtKJzoolRwEjWOTbeKqU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682037687; a=rsa-sha256; cv=none; b=qSwHTPcKHRpBxcFwpPNfzF+Y1GIQEjBvlvesECB5USA/l1g+MISNap7ZbaBj3UV31tpSeD fMptmnnuHG0KeXndbaGNKOYqfASqVmpYvFSQK++V/jly9va+VMDkXhD6NPY+w6ZSdrqwdp YXgAK77vLnS47rccsyDFzb6BskZbIpw= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=tG404iTe; spf=pass (imf30.hostedemail.com: domain of cmllamas@google.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=cmllamas@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-63b35789313so1310102b3a.3 for ; Thu, 20 Apr 2023 17:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682037685; x=1684629685; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=V9j1g7sK3q1/d39/yJUozMObHifrV7DZPVY+c2FKrBI=; b=tG404iTeIKBzFQ2afETCq9JjRtSLFROG7JgUWHjmUVO8bezWtXVh9fjsDB9qRaIpqR /9KZTJMWPrlLV74rGkMv7B4tbZNrlmUxFtH7VaISia45q5Lw9wUn5XxXswwB+SI8mV0H 2+V1tEiLlOzEgFuupmaWSol/CF5rJ2CbgUCUA1E75EJfZrMVrW8AtG/5A+o8Qb98o9xb euWEaN9Luo30IGtV6DG4HQTnL7HAOp8AkUL4lNTmoyOJw/uwGTRCnfKnTuOj/bzAbOWn XtpnK4b1vc3J4C9KitxYQNQ579ym3u+zhSl78+KkkBB8gpr9vSYLygR0mXdpPS8ZMurR aYUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682037685; x=1684629685; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=V9j1g7sK3q1/d39/yJUozMObHifrV7DZPVY+c2FKrBI=; b=NjAFaHbUMcSwCd1DHVJ9vZ2jNqMUACyZQV67LtRXLLF/bpvbP/pm1zpqy5zTxiO/qn P5Xxf0ZF366g4U9EnUNlZ7EnADmnvWQfrJPk+fMjZKmopmP8PmE2odOTJTm8FB3mFeaU soeM0iQ7bJubZRspGC6XpDOoBfbYErAb5OWexjJ2fALcOd0f/44HVUZBLQ1cVJq8gveI AhKa5KttrcPKmSfe2BK0/qgeoswWTEMtZyRxvHx+q9IGDsgQzwrAZD3OU8leEW3/WGMa mz0kkhYYvZ0VhcE7g0jxvJ6Xb06+4WtoHwEkync/hqyAg/WX+gG1Q88YdtyM7zV7o+Ns DcKQ== X-Gm-Message-State: AAQBX9dJTw2V1q2QKrmV7K5IL3wsEfipqzUfGVUZvzCRogmOrxudjxHX 7ym7uG3+oh6YfHnB0epGEQt1Bw== X-Google-Smtp-Source: AKy350bVNciq3SNwM9/Ddxv0JWqBoEq72bXp1tM1bZOuJakAJlgFz+RpCEcC6VXd3q9ffKbHa+m4YA== X-Received: by 2002:a05:6a00:14c5:b0:63f:15cc:9c1c with SMTP id w5-20020a056a0014c500b0063f15cc9c1cmr1476876pfu.34.1682037685429; Thu, 20 Apr 2023 17:41:25 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id s23-20020a62e717000000b005aa60d8545esm1813677pfh.61.2023.04.20.17.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 17:41:24 -0700 (PDT) Date: Fri, 21 Apr 2023 00:41:20 +0000 From: Carlos Llamas To: Suren Baghdasaryan Cc: linux-mm@kvack.org, tkjos@google.com, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: Using page-fault handler in binder Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspam-User: X-Rspamd-Queue-Id: DB9AC8000C X-Rspamd-Server: rspam09 X-Stat-Signature: bzfh3j1em5jn6qosbjzf9qg6cqd6zq3m X-HE-Tag: 1682037686-301560 X-HE-Meta: U2FsdGVkX1+RDSBtXkyOoYZ6jjBCnuzHKf2yBMdoZyt5zhzbqZwQzJEv2ANvETW2PjvTVsiWqSTiH5JUxFFpEQOaeF7PdsvU5YfZI5Rrq0/sSB4VnDc+MeI8rzApFG7/T8Drh4T2tkHGusJ2YGQnMkFSHGxfpoBB4pImRH2hMslFdqqdl2pcoq9ibpnyApWBVLP4BHy6AVj27rksl45X5lD7gbvxHE66X+/bAxuB4gX37gydWUavnhrdf7IQq3JHUTg2hkzBgtwm3l8GD3yYOoIDI5xVtiUgKpeH+ZVLIh63Ot64lrXyTiw8uS7i7pNE1wu2ogkw2BeVEZdrZYJO8PrBlWWHY91F68EfnSCVlnctZnvBCT24gbCHzAXgQxrqcBHp5aTEnamOPDlqvpcBaOFTMvDrZORQY4V2rnV8y+KM6Ql0AXeOt2S5xq440Kf7i54EvBnd5gjBqNq16nSgb/X/b5vwKy5Gc1P2zMO29aNoOsc1Pcwl0JRMk/R4tq753Ac2adFoJiNvAwIHwZOE5aBibqiVFCg0RxcLRKejVpKY0kWxhHFTuxWKxo5HIvu0QCe1VklHds3ckVg7TsrpQCFBR1zxZSd9JirC/A1xlh+sRMWduxKxbf37GJimjx6tqoCpMe/jiLyxn2DOjCbgNHb1CqbVGpRidURmrhQ102rG1JWDvpvLYLZ+lkEAT0ToD5mzVulGmw8fNO5WOqeXwQlicHgS8WT/EgGLgG/riW5QlrwPFudaXOaJQS6PlCk8zZpRBKA73ReiZxUG/c1+b1pGnvBKsxvwhv0aTbDiSUbT8G9T7SngD+YSP1fdJK2EL5uizg85VumMcmac9/mwmZ/SSG8hWwULrD7hcRkOwx5a5rHqiWyZRlXdMGkp+F8phM0vwi2HBUOn8GQ9lr95MBJz/3JnnYtfBYqEKDKUQad8OpC2JTGZRGise8iRmnc4pP5GVGzN/uYaebeIJnF dbL1q+zC MZngjbRryO99pfJngidKmnQQ67z06DA1RmXa8yQ6T778YZ5UfktB7Hf69pIsDxoBqhy6JmM8COi+bi7labmgRhEvtADlUwqWwRJDAQp8wiEpPDrb3qfhX6l1BgCD+LXopPRdL6y9gQ0yyhOPD4x54IZdti0L75dzSjSTnDhhdwh79gEJ38VzOgQoKUJAbqA1NNRtqOGUOr2R3yXI4yhTtATBPUSugjxxNzNx9Wpx7omPqoiORkr0gDA51rLz6bf67oXu/85D3kc8VeQyPj1Le5U6uwq6tHBxsQQuccetqTACh63LyBaU9yVu3FCDHDOsP2Sxv1r1xTPsHN7ALdVIOD4YJ9YPRy2KV5MxS0iGJ/H7J87aPS4b4WRfOr7O7ZnAhfqGPyi2HFTAi8dZ2e91iQvL3jRsLaP5LDT38Jdha69ENVXwPma1JYL0kQw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.130034, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Apr 20, 2023 at 02:35:00PM -0700, Suren Baghdasaryan wrote: > On Thu, Apr 20, 2023 at 1:34 PM Carlos Llamas wrote: > > > > Instead of caching page pointers, I believe binder could make use of > > get_user_pages_remote() and trigger a page fault as needed. Basically, > > implement something similar to access_remote_vm() but that instead does > > a copy_from_user(). However, I don't see many in-tree users of these > > routines, so I wonder if I'm overlooking something in this approach? > > Sounds doable but there might be GUP details I'm missing... > > > > > One more reason for the page caching in binder is being able to free > > pages from the shrinker's callback. Unused pages are added to an LRU > > list and we manually zap/free them when they are reclaimed. It is not > > evident to me how can binder mark a range within the vma region as > > reclaimable? > > I think you would have to release the individual pages using > put_page(). Also note that get_user_pages_remote() is being > deprecated, see: > https://elixir.bootlin.com/linux/latest/source/mm/gup.c#L2171 Yeah, I remember reading that comment but it doesn't make sense since the suggested alternatives do not support operations on _remote_ mm. I actually tracked this down and it seems the original comment was made for get_user_pages() instead, in commit f0818f472d8d ("mm: gup: add get_user_pages_locked and get_user_pages_unlocked"). The whole comment block was then carried over without update into get_user_pages_remote() in commit 1e9877902dc7 ("mm/gup: Introduce get_user_pages_remote()"). The comment block was finally switched to use the "_remote" portion in commit adc8cb406e52 ("mm/gup.c: update the documentation"). In reality, this comment should be relocated to the get_user_pages() section. > > > > > Any pointers are appreciated! > > > > -- > > Carlos Llamas