Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp638919rwb; Fri, 13 Jan 2023 02:16:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXuEgq1b0PrVYMoHtAjHmCE7fPml+o6+Uv9pYvuasTzjSgxjo7nWmd7h9EOIyIInZehxkl7J X-Received: by 2002:a05:6a20:8f25:b0:b0:2b4f:a9d9 with SMTP id b37-20020a056a208f2500b000b02b4fa9d9mr14053863pzk.5.1673604993895; Fri, 13 Jan 2023 02:16:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673604993; cv=none; d=google.com; s=arc-20160816; b=BnlKuSn6wntIgVkwdkMnZV3Fhru7v2RqEVD5SZAzipe/frdrze6u4dEGbjw3M6S7/c u1gGCWHCaF1NyOxRb9Up+/MNUQRfLPHOisWU+jTHw/I/0wG2u6ZHFVdDN/lXofgS8FLS ixoKPKuDph6H2MNqslW34NwLbzh7CNP1EicCUpnDFMzAow8T1nFqvvtk3R/kaOXWsrKi zFNTp5uc8kLyNdkl7Zmt4AlbG3EPls482y2ZLBuypqd0gf2IKOkFD5vvS/ZWbKEFdK2p qaHE+2ZSwOxRprfFJDfL9Q37s22vg6l5KgUW96zMzbzD7NzWKdAIpwdh4ciBOArfT9RK iXAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=OfYWOGUw6JcZk6BCbCEfYG54SLYJu12x8TR2uJqxvmU=; b=uREF0wYdipVRSp/1CSiqDJXhpd8hfHphdwkbsiiPCl7sMlzRnKJqYXqsL/OluAQs1c 6Ecpc8tBvP6mG550P+PV+UUykTa2JGBz3XeyfQF8AhQWGXVhBeYOJZNQcCL9DCDmzLiH GCW42txUAwOptXK2LIa3e4O026dzy+1uwVAyEc6fUF/0HfBxPJ4yfBjZ3mLeN2KiLVR9 6Hc3wDimYZ7maB5CH73kgYV2rgUNFvJ6znb0njvq5NRv4iJX01lCB5YuJbu3U7LdU3es 51PlO29iJ2iN36HuTDrY/aoo9+WwaJbBOHTmzBDjl6rUC9+1QRyFCUM3ZUKht95UABN/ itOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m16-20020a637110000000b004adff260caesi18578103pgc.361.2023.01.13.02.16.26; Fri, 13 Jan 2023 02:16:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231757AbjAMJrx (ORCPT + 51 others); Fri, 13 Jan 2023 04:47:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239600AbjAMJrQ (ORCPT ); Fri, 13 Jan 2023 04:47:16 -0500 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0699F4FD63 for ; Fri, 13 Jan 2023 01:36:11 -0800 (PST) Received: by mail-qt1-f174.google.com with SMTP id g9so3998347qtu.2 for ; Fri, 13 Jan 2023 01:36:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OfYWOGUw6JcZk6BCbCEfYG54SLYJu12x8TR2uJqxvmU=; b=lba8i3MlJTJwJPCZlDXGAbD/pMwI0YVnbcvwe7FxYMKYbG0WZmNcPlFvwZn9INgVPH R5dP1UbUFUkNzXHrtaluXitfQ5cfpmzd8tOFcY1qD12OYmxE1ZPCHXFCA5iisGmo/Otg XQCuhIL/fcFVtLlxR0fAUT+IVZUX3GPR7sEXVC97qn2FYBrJsWgsGtsmxADP/HqBV/ME 3vOYBS/Y+XM73FkH0HhraEB+pO52cdTjtocPs0cJD5tfWRDEEaZKGkJswBBpA9zclaW1 45V9QJ6Axu/O4kpCcu7FUsSIz3vQFpCKg0AlQ0u6qzC47vr7YVTy5JLY3v3fzIDl+UtN wcxQ== X-Gm-Message-State: AFqh2kqhBoQu3n88IUK17owZyoEesXKokkOVc9U9Wf0dbE5R9k4Adml4 Aal25FR7xMFPMEFtnflJBjzoToeUpcuUiA== X-Received: by 2002:a05:622a:4a15:b0:3af:b6bd:aba7 with SMTP id fv21-20020a05622a4a1500b003afb6bdaba7mr18333943qtb.43.1673602569925; Fri, 13 Jan 2023 01:36:09 -0800 (PST) Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com. [209.85.128.178]) by smtp.gmail.com with ESMTPSA id n15-20020a05620a294f00b0070383f1b6f1sm12495037qkp.31.2023.01.13.01.36.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Jan 2023 01:36:09 -0800 (PST) Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-4c24993965eso270265387b3.12 for ; Fri, 13 Jan 2023 01:36:09 -0800 (PST) X-Received: by 2002:a0d:d98c:0:b0:4dd:7a8e:1cf3 with SMTP id b134-20020a0dd98c000000b004dd7a8e1cf3mr249079ywe.384.1673602568857; Fri, 13 Jan 2023 01:36:08 -0800 (PST) MIME-Version: 1.0 References: <20230104231127.2634648-1-nphamcs@gmail.com> <20230104231127.2634648-3-nphamcs@gmail.com> In-Reply-To: <20230104231127.2634648-3-nphamcs@gmail.com> From: Geert Uytterhoeven Date: Fri, 13 Jan 2023 10:35:57 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 2/3] cachestat: implement cachestat syscall To: Nhat Pham Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, bfoster@redhat.com, willy@infradead.org, kernel-team@meta.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS 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 On Thu, Jan 5, 2023 at 12:13 AM Nhat Pham wrote: > Implement a new syscall that queries cache state of a file and > summarizes the number of cached pages, number of dirty pages, number of > pages marked for writeback, number of (recently) evicted pages, etc. in > a given range. > > NAME > cachestat - query the page cache statistics of a file. > > SYNOPSIS > #include > > struct cachestat { > __u64 nr_cache; > __u64 nr_dirty; > __u64 nr_writeback; > __u64 nr_evicted; > __u64 nr_recently_evicted; > }; > > int cachestat(unsigned int fd, off_t off, size_t len, > size_t cstat_size, struct cachestat *cstat, > unsigned int flags); > > DESCRIPTION > cachestat() queries the number of cached pages, number of dirty > pages, number of pages marked for writeback, number of evicted > pages, number of recently evicted pages, in the bytes range given by > `off` and `len`. > > An evicted page is a page that is previously in the page cache but > has been evicted since. A page is recently evicted if its last > eviction was recent enough that its reentry to the cache would > indicate that it is actively being used by the system, and that > there is memory pressure on the system. > > These values are returned in a cachestat struct, whose address is > given by the `cstat` argument. > > The `off` and `len` arguments must be non-negative integers. If > `len` > 0, the queried range is [`off`, `off` + `len`]. If `len` == > 0, we will query in the range from `off` to the end of the file. > > `cstat_size` allows users to obtain partial results. The syscall > will copy the first `csstat_size` bytes to the specified userspace > memory. `cstat_size` must be a non-negative value that is no larger > than the current size of the cachestat struct. > > The `flags` argument is unused for now, but is included for future > extensibility. User should pass 0 (i.e no flag specified). > > RETURN VALUE > On success, cachestat returns 0. On error, -1 is returned, and errno > is set to indicate the error. > > ERRORS > EFAULT cstat points to an invalid address. > > EINVAL invalid `cstat_size` or `flags` > > EBADF invalid file descriptor. > > Signed-off-by: Nhat Pham > arch/m68k/kernel/syscalls/syscall.tbl | 1 + Acked-by: Geert Uytterhoeven [m68k] Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds