Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp618095rdb; Thu, 1 Feb 2024 20:49:00 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUCCkZyvV2IZOHHO0S64gR1+L6JrCpn3Bj7aj3CzAPcHYtzxZQa6AeAUyVs+05EFn9mbeVWwH7URvdnebIW22bNr9dwMi+M+hyQ1BEgKw== X-Google-Smtp-Source: AGHT+IFeumh2mxH6jfCQC7gadKy5oFjENAvn7M/GBhywqq/fckbrGgcXtgB2W+3mLF+RIge2v+9Y X-Received: by 2002:a05:6402:22ed:b0:55f:f127:2b7f with SMTP id dn13-20020a05640222ed00b0055ff1272b7fmr311607edb.1.1706849339980; Thu, 01 Feb 2024 20:48:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706849339; cv=pass; d=google.com; s=arc-20160816; b=Q4UHJID8wbB5Vehon1/U9kuE4VAQKRmfXFtexoeS8hA5b7Y79nvQZMtcGQfOfHu9rW JwqiGaey4R2QXQzeeXbArop6Sb0ao+KihSqOurR+lZVfeLVgwpOlZMxDajcagJrskaKe ZO0Cek8uei6hnBNy4R15gwrjceybfBNAU9BYS0YDJi5KRXUi49SvDL+0yKxvRAyG9+PX fvfx75Wl1ohKkSjlXuI5hkB0FnEsnYvuR3yydyqUea2VcyrTrCqx6xojR2xa60UT0V62 eSvXrUFCuRDC5a2i+HUauSqWhoTGCMImX57vRispszYBCgjGs76ZL+BDXGy77fbyVAnj rUsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GBcHybaOTExgtSnIw6pfOqSTYi0/PYs/65WdqotfksI=; fh=7OMc3rKRLW1BWcizV87n98ZfzzoDXMOgcFJ6N2IoluY=; b=ZKlkza4y1PKlcIJywL2kD5ks6nY2h2NVSMqS8mqdHZdXBUDpon4yZeROTLDqjPYALx I/ceCTn5TC2720BOR8bAB5PAsLu+hSU432bC0DDI+gCb+7I7LgIzg86aWDRvnzvPH2q1 1AVpjcrLOvzYfTADiJwFE/y0H5+CWOOtQc8RD2L5ui5PtyqU+xU4b3vBKeaoYyHu85tB u+ztd3dI0VUkVi2cuynj4rnixKznZWfBpL2H0bGWHyxDrtLbi18BojDNt1AZMhrPl1f7 UmlxI6TXzeVSTxiKSFC855WZXhDzok75NhxOu0zGIVfjG4O6XFNVlJQ7GwrTtlVGtklQ MuPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KqoFdJi6; 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-49198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49198-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCUjtuwt9EkQPg9DyBsBXqQxwdD1z6L/iydHlVL3ErXc2IETD9bcLuZZElUs+ceH+ohrWbft/7hrxkfnr3+2tnzIJOR6BPQlWEINkiN6/A== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bx24-20020a0564020b5800b0055f8632fac1si454259edb.585.2024.02.01.20.48.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 20:48:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KqoFdJi6; 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-49198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49198-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 am.mirrors.kernel.org (Postfix) with ESMTPS id B68041F257F0 for ; Fri, 2 Feb 2024 04:48:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A23EAF9DE; Fri, 2 Feb 2024 04:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KqoFdJi6" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 1D6AFF4F6 for ; Fri, 2 Feb 2024 04:48:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706849329; cv=none; b=EsBj6XNg99NvOa1O1hQC3CvNQ811BuWv/xTkpFZNKZJQ+sxCeL+q1L4xhkPn4JmxvTUtAW0+viTn3Xqyz/C2eqD9DyE6n0Fg0moeheKbfcL3ca8g47KHI5Qj6YQR/HdvvJJixJ3GqYLgweSyjmmUMBChBwj9mZLbTxmCrYG2hFc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706849329; c=relaxed/simple; bh=MRhJrLFFGtALFkTfyB+TSCQ4/kJfsL3idSkvr2wXUuo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fbaUIJbi8sp+fNbZgGY9Gq+1/JY6HgNgQwTji80SzVne4AZpIjaXOnocnJbuuU0VYv7iSHzn33OHJJ8sVO7Ou30+Po0lmxyTb8nV++/9gAO1LeHopg8L5Q55szZLy3LUI6rOMIrk6caPJx9Ga2QUF58g4UX674J0dRgpqWK4Wk4= 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=KqoFdJi6; arc=none smtp.client-ip=170.10.129.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=1706849326; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GBcHybaOTExgtSnIw6pfOqSTYi0/PYs/65WdqotfksI=; b=KqoFdJi6fREQLBKjydvX8+6sCfJHTdqXyayeclxWuE0cxBeyQRl9qi0tS7brMayDgTqDmJ JFzWb6kiQB+V+QDs1BwigeOMLaFjcFEO9LYKg0yAf0bZoVXb/Yeg+ssq9ZC2tQ7CFl0HxR 0u1k+82hq43Dhcp4wA9grRgBVZI/mnw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-609-Ua2OcVI-PcSJtTR88LE0oA-1; Thu, 01 Feb 2024 23:48:42 -0500 X-MC-Unique: Ua2OcVI-PcSJtTR88LE0oA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 0EB0B38117FB; Fri, 2 Feb 2024 04:48:42 +0000 (UTC) Received: from fedora (unknown [10.72.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 41BD21121306; Fri, 2 Feb 2024 04:48:35 +0000 (UTC) Date: Fri, 2 Feb 2024 12:48:28 +0800 From: Ming Lei To: Matthew Wilcox Cc: Andrew Morton , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, David Hildenbrand , Alexander Viro , Christian Brauner , Don Dutile , Rafael Aquini , Dave Chinner , Mike Snitzer , ming.lei@redhat.com Subject: Re: [PATCH] mm/madvise: set ra_pages as device max request size during ADV_POPULATE_READ Message-ID: References: <20240202022029.1903629-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 On Fri, Feb 02, 2024 at 04:15:39AM +0000, Matthew Wilcox wrote: > On Fri, Feb 02, 2024 at 10:20:29AM +0800, Ming Lei wrote: > > +static struct file *madvise_override_ra_win(struct file *f, > > + unsigned long start, unsigned long end, > > + unsigned int *old_ra_pages) > > +{ > > + unsigned int io_pages; > > + > > + if (!f || !f->f_mapping || !f->f_mapping->host) > > + return NULL; > > How can ->f_mapping be NULL? How can f_mapping->host be NULL? You are right, the two checks can be removed because both two won't be NULL for opened file, and .f_ra is initialized with f->f_mapping->host->i_mapping directly too. I will drop the checks in next version. BTW, looks the same check in madvise_remove() can removed too. Thanks, Ming