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 picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2B72BCCFA03 for ; Thu, 6 Nov 2025 12:04:27 +0000 (UTC) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 94B593CEA7A for ; Thu, 6 Nov 2025 13:04:25 +0100 (CET) Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 6CBFE3C5705 for ; Thu, 6 Nov 2025 13:04:08 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 in-3.smtp.seeweb.it (Postfix) with ESMTPS id EB9A91A00A25 for ; Thu, 6 Nov 2025 13:04:07 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 15862211E5; Thu, 6 Nov 2025 12:04:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1762430647; h=from:from:reply-to:reply-to: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=f2lzY/sNz2ly7NLS7FaNO/emiZl34mjPgn9fmXsfhpQ=; b=18O8g5jAdvdSAwqhfeJl1hewJm3B9yEBwqmgLOfiFQZeEhRupgAah/qPuiCXwjQF0JLrhO soNDXuf6gvA/jY34EfE6ppU2BR35yCjyGYAqdIrgXtJyVsudC98EvnGBKN+uxX8lp5JeTS y8C9/88R8ViXE2/9POnWJTiMqG9ALbI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1762430647; h=from:from:reply-to:reply-to: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=f2lzY/sNz2ly7NLS7FaNO/emiZl34mjPgn9fmXsfhpQ=; b=VxMVjPipuP5DUOGYyr1VOlPdyeJ1se9ilNcE2MiLq0y8xzNpiJGCdlzqYh49rTaTfCA7lO JX+l0CMly2faNBAg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1762430647; h=from:from:reply-to:reply-to: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=f2lzY/sNz2ly7NLS7FaNO/emiZl34mjPgn9fmXsfhpQ=; b=18O8g5jAdvdSAwqhfeJl1hewJm3B9yEBwqmgLOfiFQZeEhRupgAah/qPuiCXwjQF0JLrhO soNDXuf6gvA/jY34EfE6ppU2BR35yCjyGYAqdIrgXtJyVsudC98EvnGBKN+uxX8lp5JeTS y8C9/88R8ViXE2/9POnWJTiMqG9ALbI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1762430647; h=from:from:reply-to:reply-to: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=f2lzY/sNz2ly7NLS7FaNO/emiZl34mjPgn9fmXsfhpQ=; b=VxMVjPipuP5DUOGYyr1VOlPdyeJ1se9ilNcE2MiLq0y8xzNpiJGCdlzqYh49rTaTfCA7lO JX+l0CMly2faNBAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CF2AF13A31; Thu, 6 Nov 2025 12:04:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id R+1dMbaODGluMwAAD6G6ig (envelope-from ); Thu, 06 Nov 2025 12:04:06 +0000 Date: Thu, 6 Nov 2025 13:03:57 +0100 From: Petr Vorel To: Avinesh Kumar Message-ID: <20251106120357.GA1013980@pevik> References: <20251105154716.995786-1-pvorel@suse.cz> <20251105154716.995786-3-pvorel@suse.cz> <2396783.ElGaqSPkdT@thinkpad> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2396783.ElGaqSPkdT@thinkpad> X-Spamd-Result: default: False [-7.50 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; HAS_REPLYTO(0.30)[pvorel@suse.cz]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; MISSING_XM_UA(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.cz:replyto]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; REPLYTO_EQ_FROM(0.00)[] X-Virus-Scanned: clamav-milter 1.0.9 at in-3.smtp.seeweb.it X-Virus-Status: Clean Subject: Re: [LTP] [PATCH 2/3] swapon03: Try to swapon() as many files until it fails X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Petr Vorel Cc: Michal Hocko , ltp@lists.linux.it Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-bounces+ltp=archiver.kernel.org@lists.linux.it Sender: "ltp" > Hi Petr, > some comments inline +1 ... > > - /* Determine how many more files are to be created */ > > - max_swapfiles = tst_max_swapfiles(); > > used_swapfiles = tst_count_swaps(); > > - swapfiles = max_swapfiles - used_swapfiles; > > - if (swapfiles > max_swapfiles) > > - swapfiles = max_swapfiles; > > + expected_swapfiles = NUM_SWAP_FILES - used_swapfiles; > > + > > + if (expected_swapfiles < 0) { > do we want to proceed when expected_swapfiles is 0 here? Yes, because NUM_SWAP_FILES is 15, which is safe for the changes. I.e. on my Tumbleweed VM it can be 23 swaps. One is used as filesystem partition, therefore it would work on even 22. > > + tst_brk(TCONF, "Warning: too many used swap files (%d)", > > + expected_swapfiles); > I think this should be used_swapfiles ? +1. Also I should remove "Warning: " (left over from previous not-yet-sent version which used tst_res(TWARN)). I'd also prefer either to improve grep or replace it with C based search (better as it does not require grep). > > + } > > pid = SAFE_FORK(); > > if (pid == 0) { > > - /*create and turn on remaining swapfiles */ > > - for (j = 0; j < swapfiles; j++) { > > - > > + while (true) { > > /* Create the swapfile */ > > - snprintf(filename, sizeof(filename), "%s%02d", TEST_FILE, j + 2); > > + snprintf(filename, sizeof(filename), "%s%02d", TEST_FILE, *swapfiles); > > MAKE_SMALL_SWAPFILE(filename); > > - /* turn on the swap file */ > > - TST_EXP_PASS_SILENT(swapon(filename, 0)); > > + /* Quit on a first swap file over max */ > > + if (swapon(filename, 0) == -1) > so now first swapon() fail is here and then we check for errno==EPERM by > making another swapon() call in verify_swapon function. > Is it possible to combine setup_swap() and verify_swapon() and check for > EPERM on first swapon() fail itself? I was thinking about it as well. To support -i, we still need to have setup run only once. Moving code from setup to test function would require to run "setup" part only once (guard with static variable). Other option would be to keep setup, but test errno also here (i.e. test it twice). I'm not sure which one is less awkward. Kind regards, Petr > > + break; > > + (*swapfiles)++; > > } > > exit(0); > > } else { > > waitpid(pid, &status, 0); > > } > > - if (WEXITSTATUS(status)) > > + if (WEXITSTATUS(status) || *swapfiles == 0) > > tst_brk(TBROK, "Failed to setup swap files"); ... -- Mailing list info: https://lists.linux.it/listinfo/ltp