Received: by 2002:ac8:6216:0:b0:41c:c224:f26f with SMTP id ks22csp78071qtb; Thu, 2 Nov 2023 12:03:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETmT5WSM5G7RW9EIpBkwodeJMctEjzPKy5gSTO2bQiKbLH6sB7KAukt/7h0WwHm8+PK3pj X-Received: by 2002:a05:6a00:2341:b0:692:b6e8:ce88 with SMTP id j1-20020a056a00234100b00692b6e8ce88mr18656021pfj.17.1698951811810; Thu, 02 Nov 2023 12:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698951811; cv=none; d=google.com; s=arc-20160816; b=N4HEY8c5R41XAlRuoVuSn2X6Hj6VVXSMgZiM3ZZg1fOVzV4c623maZ+j6hIzAIUON6 0JAn/FwbipYEiJx7Xm8C60FLumzwKhQxA8DF6U+j8Dwh/r7bwBWpodyuO7ZWWehxTrQ0 Deu9gkzXWv074C76rEjoj91ouufT+NsDR82Q6B6bJOzL+puhphKVxqbMFBIcTks2/DDJ DEHYjus6sCskxz08TpGcotdZOl9uJ13HTEfAqllrdyMtlprL6M3I3TyK6NrvwGTebo0c 6TH3tCE5V68pURvDspgo0p5NV4bm4URVapHS+H7bMTJfPliaF15G7c+PDVpGGVWTodcP XV6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=QHIOo3gOkAYOw4RGs9b01yoCrC6Uyqd0reVAR+tEFcA=; fh=CZn2LCtibpDsl0Zo9a9tnbwjfnRU9o2A0KEGhAadkDo=; b=wCoFYmqZVb3G+2zrD6xvS7nnphDL+uwZ+z7b8/e4Lon8lwRwgK1kqI155YZ0dBbv7D 2LHmSogyy3nd5ehyAkColo5QRWSEtaIC7CMVv/YbgfAFDkHM8x0M2Zdqw4qcOcJI5mI2 43k9n4xEMH9Am5iAJdPyYhNdlm48P1gwf59PJYBjj/J8eTx8OC7LQvIS+NsbVmqbMXjl zJfczyAfUd73UVrwxQi4raZMxJWmZzlihlcmFulGnMtnm8FlKNhpfUSCh+T3atVUPrQM 0JOl4OtnTRqLBiawzPYSzLQ8L0RgVBuAmwG581VZVW4CvP50a/WSfHWwncxPEsutQ9W4 X4Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xRfGfhQH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id p34-20020a056a0026e200b006c33c1c00d5si141799pfw.96.2023.11.02.12.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 12:03:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xRfGfhQH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 06EB282291B6; Thu, 2 Nov 2023 12:03:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377517AbjKBTCI (ORCPT + 99 others); Thu, 2 Nov 2023 15:02:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377404AbjKBTBf (ORCPT ); Thu, 2 Nov 2023 15:01:35 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBE98D4F for ; Thu, 2 Nov 2023 12:01:11 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-5aaae6f46e1so1135899a12.3 for ; Thu, 02 Nov 2023 12:01:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698951671; x=1699556471; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QHIOo3gOkAYOw4RGs9b01yoCrC6Uyqd0reVAR+tEFcA=; b=xRfGfhQHGBAC/46JjNQm2SjxXf737mvXI7vZsYGswrpQ5DSYHv2AVPpme/7qszzH2I rL4QSyT1/Imaux3eEpVlUiLj8sA1OpltUh6J0/pqsNDOoKDQPJbiGiPaDMPuZ0Es90N2 6M/ZwRZk7utp9F5FwRToSk11od1Ip0Op5ub5giI8lymLS212dXfauhIscgEsOU3kt1ki U+1Y0eS7gk6+X4zhL3MMvJibptpUCSPa/JySOKyQrK+2Q3+jM1Vcr/+X5XwylkPXPLg+ jzq8negxgRTJVf7/815h/J81v5m3yZez5VRX4EBZtVDzOEFACtyoo6XZ8zB/LP9sv5KV OMMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698951671; x=1699556471; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QHIOo3gOkAYOw4RGs9b01yoCrC6Uyqd0reVAR+tEFcA=; b=AN27eQzxMu+3bs80tHz4TqLyvp0atEy4T1GC4W0q8T7WpoNiXBr5k/ZdwZaD1g+ZSy 8kaLGwCVePJHVz+G1eBuHhwUGayIlb5ENRku1Td8qhuujpxYgNnKjLjWazeKnMDpiMuR zEUTeYHwgNJP31N4c9jFzJnVyPYxtVqF1rSG3Hpmjh7GxGfNmwFj8LsKYw20FW++TT32 NN1W4t0Vc2HsTe9EB4Gf53RJpF8rzyzYozlNobREFdSeLsZSfOypiCzNTsg+6zk1JdMu n7eTBja3w707tmDIF5QSLE7Ix3GUTUGUuQzuHKWMP4foQxb7KEUTW3tl/PfhFXV+833Q T9lw== X-Gm-Message-State: AOJu0YxvN4JW0yWKvHFa0aYgTxRGALzGso+xiWD0DCrqKUJ6UcDuR3Vp Sv40YxwPVnvEwuZtAgOs+4M6KqAuEJL9jA== X-Received: from xllamas.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5070]) (user=cmllamas job=sendgmr) by 2002:a63:36c2:0:b0:5b9:803b:1fbc with SMTP id d185-20020a6336c2000000b005b9803b1fbcmr235490pga.12.1698951671343; Thu, 02 Nov 2023 12:01:11 -0700 (PDT) Date: Thu, 2 Nov 2023 18:59:19 +0000 In-Reply-To: <20231102185934.773885-1-cmllamas@google.com> Mime-Version: 1.0 References: <20231102185934.773885-1-cmllamas@google.com> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog Message-ID: <20231102185934.773885-19-cmllamas@google.com> Subject: [PATCH 18/21] binder: initialize lru pages in mmap callback From: Carlos Llamas To: Greg Kroah-Hartman , "=?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?=" , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan Cc: linux-kernel@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 02 Nov 2023 12:03:23 -0700 (PDT) Rather than repeatedly initializing some of the binder_lru_page members during binder_alloc_new_buf(), perform this initialization just once in binder_alloc_mmap_handler(), after the pages have been created. Signed-off-by: Carlos Llamas --- drivers/android/binder_alloc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c index da6c62567ffb..7e0af1786b20 100644 --- a/drivers/android/binder_alloc.c +++ b/drivers/android/binder_alloc.c @@ -278,9 +278,6 @@ static int binder_allocate_page_range(struct binder_alloc *alloc, trace_binder_alloc_page_start(alloc, index); - page->alloc = alloc; - INIT_LIST_HEAD(&page->lru); - ret = binder_get_user_page_remote(alloc, page, page_addr); if (ret) { binder_free_page_range(alloc, start, page_addr); @@ -791,9 +788,9 @@ void binder_alloc_free_buf(struct binder_alloc *alloc, int binder_alloc_mmap_handler(struct binder_alloc *alloc, struct vm_area_struct *vma) { - int ret; - const char *failure_string; struct binder_buffer *buffer; + const char *failure_string; + int ret, i; if (unlikely(vma->vm_mm != alloc->mm)) { ret = -EINVAL; @@ -822,6 +819,11 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc, goto err_alloc_pages_failed; } + for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) { + alloc->pages[i].alloc = alloc; + INIT_LIST_HEAD(&alloc->pages[i].lru); + } + buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); if (!buffer) { ret = -ENOMEM; -- 2.42.0.869.gea05f2083d-goog