Received: by 2002:a05:7208:31d3:b0:81:e143:7c29 with SMTP id v19csp2636856rbd; Tue, 9 Apr 2024 12:32:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXQ7DNJ5OQi4rOMTngsO2CV3TzRqsElJSRJurH4HF51GktlEY729bH2H6lqghWxqS4xaltAkdU+DnFIv1CL3/2y5BPDAKkf9LKO0ORGVg== X-Google-Smtp-Source: AGHT+IGKNpc5nxlHCWe4VMH5P8KB8azj1UpKr7xTrN8iwatrfnaw+xK4ZKRCsBRLzpPdyIgZZfGU X-Received: by 2002:a17:90a:4982:b0:2a2:f25c:c250 with SMTP id d2-20020a17090a498200b002a2f25cc250mr663087pjh.11.1712691173783; Tue, 09 Apr 2024 12:32:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712691173; cv=pass; d=google.com; s=arc-20160816; b=h+tc54DW/EGAPCRqQ+Ufgri+1DioEXL/mk2PiMwV5OAM2Iq1Wky0DpImoDVw1A/I7j CjW+TdXyiV03deh8so+FKmKuE1IgCU4DzusY/oLrHNB9NYh1Y+cGMubm4Q708by6BGdy dehk+8YXuAM01oL9NnkuDAuR1FvCrxWnNWP/k8jbCIUbtSIE2/paOA4JxkQLwP+6ddzr kk4FM+aeTw90tyqh/tPL6XZscvQIt1uVM76997cE+qLsjihbo0HN1OxqpOQ7cTh0LXE8 E/5jZg7RAmE+lPaaU0Q8GhvV0/psq6qRokKe5J0YhiS4mxlstUwFi2+bFRV97+81mypw wxBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=oja6emUhi7xfrQgd9sof78Ea2rpQTjm332kNskpFfoE=; fh=6UXOkRl8PLWnLRlJFkZ1FKxRpZrfO06mwvecZ/lFyqY=; b=IWwvOzynTogO5J1wPHp6SZVxUkA0lfUxqnYrHEvQ5NpCSKFCzjdUdKGLDy/mTGHdmA DXOW72dT5H8N4Th2XADpVrDshtdlDAZnCKIIYqDb0an15kHiyvbsp6Dap437ZoFgt4qu I9baBMQ3p1zje7M81oi/F/bNX5qmKZNYK4UyVBvhRUWooVIoEwcC0oiQxPAsYcFs2q3s uaatoLqHvthUiHbCvHsEpsXGA2tWWR0eLKe+SqcloW/wKjukWPgIx9fB5sWEphwBR+Nf r1zcQqH/xMT4HV/6n7jdeHtpm2AhR9RnrBmOoic2LvEmzRhL3nzLUKiF6o+48wpQFYL2 xsHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TNLaC2v1; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-137530-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137530-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id rj4-20020a17090b3e8400b0029bb8f40085si11508019pjb.18.2024.04.09.12.32.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:32:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137530-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TNLaC2v1; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-137530-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137530-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E6187B23BD1 for ; Tue, 9 Apr 2024 19:28:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B7A0157E7E; Tue, 9 Apr 2024 19:26:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TNLaC2v1" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 456E7157E77 for ; Tue, 9 Apr 2024 19:26:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712690764; cv=none; b=AkOoDSq0X5sNbMUOgt7RvfGrvn/w5xfb2qd8iTwPiy9u/MBw54eR8+ftmzCW12dvgd6owIrePHWMVVrnQ0FZO+J/wVwxp7O2oHPaTx6FqbCtj8nrnHS746WS09c46dt5DBcXbNCFd+veKO5vaHYSnBYj2KQGt3cRgcAPFHU5H3E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712690764; c=relaxed/simple; bh=B9VW3LrHsx1zgfIxNNfkZUFwrAR512abN6D1CTPxM7s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YNEhirKPqv0tXxzc99pfsA3Okfi3B5ANJ5TFZK9S1/dTZNknyvydos9ERI9O3KW2AKV4tEvlSM2BNOoP7IkV4rmky5rdxcCUdICLVQ6SCl5uP2iPB/Y9f/XnoQ8NM3/cu8heRqgu58RbSkddLF2A9XIM8WQG1HyRlUxXiqeZmk4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TNLaC2v1; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712690762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oja6emUhi7xfrQgd9sof78Ea2rpQTjm332kNskpFfoE=; b=TNLaC2v1HR2uT0oXzQoW0iyFdppQd9oxnjMU6FeNeFb7SNKy0Ua/LW+k9rqRIo3NuVig7r znyo65SDJECdzHoF2H08IlQLm7qz+8vrMKw7eMhHrWrRoDjyu3STc1BpwXsNgleoWkjKkG lG+NEI8n6Sn6xFZNjbaoDDv/LcobVXU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-216-euyj5-iiOp6e2NecV838wQ-1; Tue, 09 Apr 2024 15:25:57 -0400 X-MC-Unique: euyj5-iiOp6e2NecV838wQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 262C9800198; Tue, 9 Apr 2024 19:25:56 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B6EB40B497D; Tue, 9 Apr 2024 19:25:43 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, cgroups@vger.kernel.org, linux-sh@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Peter Xu , Ryan Roberts , Yin Fengwei , Yang Shi , Zi Yan , Jonathan Corbet , Hugh Dickins , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Chris Zankel , Max Filippov , Muchun Song , Miaohe Lin , Naoya Horiguchi , Richard Chang Subject: [PATCH v1 12/18] sh/mm/cache: use folio_mapped() in copy_from_user_page() Date: Tue, 9 Apr 2024 21:22:55 +0200 Message-ID: <20240409192301.907377-13-david@redhat.com> In-Reply-To: <20240409192301.907377-1-david@redhat.com> References: <20240409192301.907377-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 We want to limit the use of page_mapcount() to the places where it is absolutely necessary. We're already using folio_mapped in copy_user_highpage() and copy_to_user_page() for a similar purpose so ... let's also simply use it for copy_from_user_page(). There is no change for small folios. Likely we won't stumble over many large folios on sh in that code either way. Signed-off-by: David Hildenbrand --- arch/sh/mm/cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sh/mm/cache.c b/arch/sh/mm/cache.c index 9bcaa5619eab..d8be352e14d2 100644 --- a/arch/sh/mm/cache.c +++ b/arch/sh/mm/cache.c @@ -84,7 +84,7 @@ void copy_from_user_page(struct vm_area_struct *vma, struct page *page, { struct folio *folio = page_folio(page); - if (boot_cpu_data.dcache.n_aliases && page_mapcount(page) && + if (boot_cpu_data.dcache.n_aliases && folio_mapped(folio) && test_bit(PG_dcache_clean, &folio->flags)) { void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK); memcpy(dst, vfrom, len); -- 2.44.0